Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for new -e/--environment CLI argument for dotnet run #44867

Open
baronfel opened this issue Feb 12, 2025 · 0 comments
Open

Comments

@baronfel
Copy link
Member

baronfel commented Feb 12, 2025

Type of issue

Missing information

Description

In 9.0.200 we added a new argument to the run command to allow explicitly setting environment variables in the process that will be run, as opposed to applying them to the .NET CLI and the process that will be run.

We need to document this argument, as well as have a section describing the way that environment variables are passed to the application that is launched.

The short version of how env variables are applied is that there are four mechanisms that can apply env variables to an application launched by dotnet run:

  • ambient environment variables from the operating system when the command is run
  • System.CommandLine env directives, like [env:key=value] - these apply to the entire dotnet run process, not just the project being run by dotnet run
  • environmentVariables from the chosen launch profile (-lp) in the project's launchSettings.json if any - these apply to the project being run by dotnet run
  • (new) -e/--environment CLI option values - these apply to the project being run by dotnet run

The environment is constructed in this same order as well, so the -e option has the highest-precedence.

Page URL

https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-run

Content source URL

https://github.com/dotnet/docs/blob/main/docs/core/tools/dotnet-run.md

Document Version Independent Id

7e78f9f5-f77c-828d-ef76-8ef8593d5803

Article author

@tdykstra

Metadata

  • ID: fd3f4227-cd9b-7b1c-7e1b-ffb3d42ae496
  • PlatformId: a7c8b306-df1b-bfae-f387-a4da37ef26ca
  • Service: dotnet-fundamentals

Related Issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 Ready
Development

No branches or pull requests

3 participants