I would like to have 2 debug profiles in my launchSettngs.json file (1 for Kestrel and 1 for Docker).
In both cases, I want to pass environment variables to the application.
I want the variables set at the process level to avoid conflicts between apps. So, no user or machine level variables.
I do not want to supply the values in the environmentVariables section of the launchSettings.json file because:
- I do not want these values checked into source control
- I don't really want these values even persisted to disk
- These values exist in a cloud vault and should be retrieved dynamically prior to execution of the application based on the authentication of the current developer.
I also do not want the code to have to fetch the environment variables from the vault itself. I want the code to be agnostic. In production, the infrastructure should supply the values to the container. So, locally, the dev tooling should supply the values to the app.
And, of course, I want to still be able to F5 in Visual Studio and use the debugger.
Ideally, I could specify a pre-run script in my launchSettings.json file that would go get the values from the vault and setup the env vars for the shell that Visual Studio is launching.
Is there a way to do such a thing? If so, how?
If it matters, I can use VS2022 and .Net 6.