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

167,077

Solution 1

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

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

Share:
167,077

Related videos on Youtube

rianjs
Author by

rianjs

Delivery-focused software developer. I really enjoy working at the intersection of computer science and operations research.

Updated on July 08, 2022

Comments

  • rianjs
    rianjs almost 2 years

    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?

    • Richard
      Richard about 7 years
      Possible duplicate of TFS 2015 build task for VS 2017
    • rianjs
      rianjs about 7 years
      That question is phrased with a bad title that hides the real question. It didn't come up in a search. Your answer is a link and run, which is bad. The number of views is low, and it's "newer" than this one in a way that won't matter a day from now, let alone next year. So sure, it's a "duplicate" in the worst possible sense.
    • qxotk
      qxotk over 5 years
      I disagree with the suggestion of a duplicate. I found this SO q&a as top result for my search for: "how to install msbuild 2017 on build server" - and the top answer addresses my need precisely. Having read the suggested duplicate, that answer is a full level more detailed about issues moving from one version to another - that SO post does not answer the question I searched for.
    • RBT
      RBT about 4 years
  • Itamaram
    Itamaram about 7 years
    The abovementioned directory is definitely not created. I've removed the --quiet flag with identical result, except for a modal window popping up for a bit before disappearing.
  • rianjs
    rianjs about 7 years
    I would have a look at the Windows Event Viewer to see if there are any log messages about why the installation failed. And then correct those or ask a new question that's specific to your problem.
  • cwills
    cwills about 7 years
    Also, dont use --quiet mode if you're building ASP.net web applications on your build server - as you will want to select "Web development build tools" during the install wizard so that the correct MSBuild targets are installed.
  • lorond
    lorond about 7 years
    Looks like instead of build tools link refers to vs community. Here is buildtools link: aka.ms/vs/15/release/vs_buildtools.exe
  • Avi Kenjale
    Avi Kenjale almost 7 years
    @rianjs, I installed this on my build server(Bamboo), however when solution gets built, it throws error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Sdks\Microsoft.NET.Sdk.Web\Sd‌​‌​k\Sdk.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. unable to understand why it still doesn't find this path.
  • Dib
    Dib almost 7 years
    I installed this and package restore via NuGet does not seem to work. Any one else experience this?
  • LazyProgrammer
    LazyProgrammer over 6 years
    Is there an offline version of this ? My build server has no internet access.
  • Michel de Becdelièvre
    Michel de Becdelièvre over 6 years
    @IamCP : to copy VS2017 installation environment into a local machine : cd G:\ISO; .\vs_Professional.exe --layout G:\ISO\VS2017ProOffline --lang en-US ; .\vs_BuildTools.exe --layout G:\ISO\VS2017BuildToolsOffline --lang en-US ; Then you can copy to your offline target.
  • morgwai
    morgwai over 6 years
    unfortunately at the moment MSBuild from the suggested package is affected by this issue, which manifests itself with The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. Please upvote the issue, so that M$ finally fixes it.
  • Michael Adamission
    Michael Adamission about 6 years
    --quiet flag failed for me. The Installer folder was there but no other folders where the msbuild should have been. I was able to confirm by digging in the log, which is in c:\users[username]\appdata\local\temp. The error was saying that it could not find the component specified Microsoft.VisualStudio.Workload.MSBuildTools. It did seem to work ok in --passive mode though. weird.
  • Auspex
    Auspex over 5 years
    I'd guess this isn't "much quicker than the full IDE." If you had vs_buildtools available, you already had the dotnet framework installed. On a server without a current dotnet, it just spent 20 minutes installing the framework, and is currently taking its time with dotnet core. If you'd installed the full Visual Studio, on a new system, it would have had to do all that, too. Still, I got what I needed from the answer :-)
  • blissweb
    blissweb about 5 years
    I did not use quiet and it came up with the gui and an option which was 71MB and previously unavailable. But after that had been displayed I had to press Install to continue. Seemed to work ok. Thanks.
  • developer
    developer almost 5 years
    I need to install it on a build server which does not have internet connection. Is there anyway to download it for offline installation?
  • gravidThoughts
    gravidThoughts over 4 years
    I love how someone edited the answer to give a link to the Visual Studio 2019 build tools. Let's make this issue even more confusing.
  • Basj
    Basj almost 4 years
    I wanted a GUI-less terminal only solution, but --quiet mode is not very good: it returns very quickly, and the installation continues in background process vs_installerservice.exe and you have no way to know the progress (1% ? 100%? 50%? failed?). Here there is no verbosity at all :(