How do I run msbuild from the command line using Windows SDK
How do I run msbuild from the command line using Windows SDK

How do I run MSBuild from the command line using Windows SDK

Option 1 (Best Option)

cd C:\ProjectFolder\
devenv Project.sln /rebuild 

Option 2

MSBuild is now part of Visual Studio.
in Command Prompt, you simply have to add the path to the .NET 4 Framework install on your machine to the

PATH

environment variable.

You can access the environment variables by:

  1. Right-clicking on Computer
  2. Click Properties
  3. Then click Advanced system settings on the left navigation bar
  4. On the next dialog box click Environment variables
  5. Scroll down to PATH
  6. Edit it to include your path to the framework (don’t forget a “;” after the last entry in here).

MSBuild is now located inside the Visual Studio folder.

For example:

c:\Program Files (x86)\Microsoft Visual Studio19\Enterprise\MSBuild\Current\Bin\
c:\Program Files (x86)\Microsoft Visual Studio19\Professional\MSBuild\Current\Bin\
c:\Program Files (x86)\Microsoft Visual Studio19\Community\MSBuild\Current\Bin\

To dynamically find Visual Studio the following can be used:

"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
D:\Program Files (x86)\Microsoft Visual Studio19\Professional

For reference, my path was

C:\Windows\Microsoft.NET\Framework\v4.0.30319

Update:

As of MSBuild 12 (2013)/VS 2013/.NET 4.5.1+ and onward MSBuild is now installed as a part of Visual Studio.

For reference, with VS2015 installed my machine my path is

C:\Program Files (x86)\MSBuild.0\Bin
4.7/5 - (4 votes)