How to start a number of processes in C # and save their environment settings?

I am developing an auto builder who will follow a series of steps in our build process and build our target application. We used to use a batch file that set up a bunch of environment variables or called tools that set environment variables and ultimately run make.

I use the "Process" class, which is great for executing these commands, but, unfortunately, every time you start, which makes changes to the environment (for example, adds something to the PATH), these variables are lost when it completes " Process ", Next" Process "is created and inherits env from the" call "application (my exe) again, which means that all env settings for the last command are lost. How do you deal with this situation? Is there a better way to run a series of batch files, such as C # commands, and maintain the environment they created?

Please note that, unfortunately, older students stated that nant / ant is not an option, so "Hey, why not use Nant - it is!" this is not the answer i am looking for.

Thank.

+3
source share
5 answers

I would suggest some code that would save the environment variables in an external file, and then you can get these variables through an external file at the beginning of the following processes.

0
source

Well, the System.Environment.SetEnvironmentVariable () method allows you to specify the scope for the variable you set. Is this what you are looking for? Not sure what I understand.

0
source

CruiseControl.net NAnt script. .

NAnt script -D: .

0

, . ( ProcessStartInfo.) , . , . , , / . , .

0

(*). , - .

(*), , , OS-.

0

Source: https://habr.com/ru/post/1697544/


All Articles