Skip to content

[dotnet-run] Allow overriding launch profile environment variable values #45740

Open
@tmat

Description

dotnet run -lp Profile uses env variables from the specified profile and ignores the values set in the current environment.
This is true even when the environment variable is explicitly set via an environment directive, e.g. dotnet [env:X=Y] -lp Profile.
As a result, there is no way to override an environment variable value set in the profile.

dotnet-watch launches projects via dotnet run. When invoked by Aspire DCP server it needs to implement Aspire launch profile semantics, which require any explicitly specified environment variable value to override the value in the launch profile. To implement this protocol correctly we need to be able to invoke dotnet run with specified env variable values overridden.

Possible options:

  • change run to only set env vars from the LP if there isn't a value already set in the executing environment [breaking change]
  • change run to only set env vars from the LP if there isn't a value already set in the by [env:X=Y] directive [less breaking]
  • change run to have a new -e/--environment KEY=VALUE option that can be used to override the value [almost not breaking]

Note:
Command line arguments passed explicitly on dotnet run command line override those specified in launch profile. This is the desired behavior and it seems environment variables should behave the same way.

Related env variable directive issue:
#40484

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions