I'm creating an extension for visual studio and one of the requested feature is that it is able to change an environment variable to one of several options, which will then be inherited by the application being developed once it is debugged.
I have tried the following
Environment.SetEnvironmentVariable("foo", "bar", EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("foo", "bar", EnvironmentVariableTarget.Machine);
but while that persists the variable, it does not seem to pass it on to the program once I hit run.
I'm looking for other ways of doing this to try, and I don't mind if they're hacky.
Edit: For clarification, this process should be transparent to the (arbitrary) program being debugged. It must also be a programmatic solution