dotnet / dotnet/project-system

Setup script, .env file support in launchSettings.json

Open
#8,189 20 comments 5 reactions 1 assignee Claimed by @mckennabarlow View on GitHub
Feature-Debugging Triage-Investigate
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

In production we use Linux .env files to configure large numbers of environment variables. For Windows development, we can use a JSON file (user secrets) for this purpose but this is a completely incompatible format so difficult to do things like maintain a common subset of variables or temporarily test somewhere variables from another environment. With WSL2, we can create something like a "local prod" environment but can't easily run it with a specified .env file. Note that .env files allow environment variables to be specified outside of the project repo (like user secrets). Docker also makes extensive use of .env files which should really be specified in launchSettings (there is currently a setting at .csproj level) so that they can be added only when appropriate (.e.g. perhaps not in "Development" if user secrets are used in that case).

Sometimes instead of using .env files we'd like to run a startup script which might e.g. create an environment based on parameters or obtain secrets from a cloud source. We may not wish to put this in our code in order to ensure same behaviour regardless of how an environment is set up.

The current options of directly-specified launchSettings.json environment variables (very bad for open source repos) or use of user secrets (in JSON) seem very limiting.

### Describe the solution you'd like

Support of .env files and setup scripts (e.g. bash or PowerShell) in launchSettings for Windows, WSL2 and Docker launch scenarios.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.