How can I install the VS2017 version of msbuild on a build server without installing the IDE?

MsbuildVisual Studio-2017Visual Studio-2019Build ToolsBuild Server

Msbuild Problem Overview


Historically, this has been done with the Microsoft Build Tools. But it seems that the Build Tools may not be available for versions after 2015. The replacement appears to be the Visual Studio build tools, which doesn't seem to have a real homepage yet.

I downloaded the VS2017 Professional installer, and went to the Individual Components tab. Right away, the summary is telling me that the Visual Studio core editor is there, taking up 753MB. I don't want the editor. Just msbuild. There is no way to unselect the editor.

Is there a way I can install the latest version of msbuild without also installing the Visual Studio IDE?

Msbuild Solutions


Solution 1 - Msbuild

The Visual Studio Build tools are a different download than the IDE. They appear to be a pretty small subset, and they're called Build Tools for Visual Studio 2019 (download).

You can use the GUI to do the installation, or you can script the installation of msbuild:

vs_buildtools.exe --add Microsoft.VisualStudio.Workload.MSBuildTools --quiet

Microsoft.VisualStudio.Workload.MSBuildTools is a "wrapper" ID for the three subcomponents you need:

  • Microsoft.Component.MSBuild
  • Microsoft.VisualStudio.Component.CoreBuildTools
  • Microsoft.VisualStudio.Component.Roslyn.Compiler

You can find documentation about the other available CLI switches here.

The build tools installation is much quicker than the full IDE. In my test, it took 5-10 seconds. With --quiet there is no progress indicator other than a brief cursor change. If the installation was successful, you should be able to see the build tools in %programfiles(x86)%\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin.

If you don't see them there, try running without --quiet to see any error messages that may occur during installation.

Solution 2 - Msbuild

For MsBuild 17, which is part of VS2022, you need to download the Build tools for VS2022 here (which is actually just the installer):

https://aka.ms/vs/17/release/vs_BuildTools.exe

(This link can be found by going to https://visualstudio.microsoft.com/downloads and scrolling all the way down to "Build Tools for Visual Studio 2022".)

Once downloaded you can install by typing:

vs_buildtools.exe --add Microsoft.VisualStudio.Workload.MSBuildTools --quiet --wait

Depending on your needs you might also need to specify --includeRecommended and possibly --includeOptional.

If you are doing web development you probably also want to add --add Microsoft.VisualStudio.Workload.WebBuildTools.

Input parameters and return codes are available here:

https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionrianjsView Question on Stackoverflow
Solution 1 - MsbuildrianjsView Answer on Stackoverflow
Solution 2 - MsbuildRocklanView Answer on Stackoverflow