Set an environment variable as part of a Visual Studio multi-project startup config
I have a solution with 2 main startup configs, V3 and V4, each with a good few API projects. Each of these projects reads environment variables from a text file at startup, but for the V3 config they must read one text file, and for the V4 config the must read another text file.
Right now each time I switch configs, I have to go and edit the environment variable loader to use the correct file, and this is very easy to forget, so I am trying to find a way to use the startup config to determine which variable file gets read.
The best I've been able to come up with so var is adding a little console app to the solution, and to both startup configs. In the V3 config the console app starts up with a V3_Environment launchsettings profile, which sets a DEBUG_ENV_VAR_FILE environment variable, and for the V4 startup, the same console app starts up with a V3_Environment launchsettings profile, setting the same variable to a different value. Then the environment variable loader uses this variable to determine which file to load the variables from.
I was hoping I could set the DEBUG_ENV_VAR_FILE variable using a build property, but in the multi-project startup config, the only per project setting is which launchsettings profile to use, and there are no global settings per startup profile.
0 Replies