[dotnet-run] Allow overriding launch profile environment variable values #45740
Labels
Area-CLI
needs team triage
Requires a full team discussion
untriaged
Request triage from a team member
Milestone
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 viadotnet 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:
run
to only set env vars from the LP if there isn't a value already set in the executing environment [breaking 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]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
The text was updated successfully, but these errors were encountered: