Take the 2-minute tour ×

I'm trying to setup .NET (C#) build from the command line. What is the list of environment variables that I need to set up in the MSDOS prompt before I can run MSBuild.exe from the command line?

The path to MSBuild executable would be the most obvious example. I cannot rely on setting variables from MyComputer -> Properties -> Advanced -> Enviroment Variables so I really need a full list if such list exists.

P.S. The build needs to be automated (command line), and I'm not using Visual Studio but building with .NET Framework (v3.5) only.

share|improve this question

5 Answers 5

up vote 4 down vote accepted


MSBuild has a set of reserved properties that are used, but you don't need to do anything to set these up. Any variables that MSBuild needs will be setup within MSBuild. The only environmental variables you need to worry about are ones that you yourself require.

The physical path to MSBuild for your DOS script is:

share|improve this answer

In the Visual Studio installation there is the batch file, vsvars32.bat, that will set the environment variables. If you want the list, then record the full list of environment variables before and after calling it, e.g. in a command line window:


And find the difference between the two lists.

(Your path to vsvars32.bat may vary...)

share|improve this answer

You don't need to set any environment variables when calling MSBuild. If your build scripts rely on a set of environment variables, then you will have to set those yourself. As for the default build process no special environment variables are required.

share|improve this answer

Visual Studio comes with a program that will set all of the required command line variables for you in a command shell. It is recommended that you run that, this will give you cmd in a window that you can compile any of the different languages.

share|improve this answer
No can do. I'm using a different ways of setting the environment and I need a list of variables. I guess I need to go and dig up that batch file you mentioned –  Bostone Sep 25 '09 at 22:25
And I'm building with .NET framework only - no VS involved –  Bostone Sep 25 '09 at 22:26

no need for a environment variable. Just make sure you have this reg key set: (note for 64bit VS, slightly different path for Visual Studio 32bit)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\4.0] "MSBuildOverrideTasksPath"="C:\windows\Microsoft.NET\Framework64\v4.0.30319\"

the you can just type msbuild at command prompt

share|improve this answer

Your Answer


