0

How do I target MSBuild 15.0 on my server? I have 15.0 installed on the server but my project is still building with 14.0. I know that Microsoft has made some changes to the directory locations and no longer uses the registry values with 15.0.

I found 15.0 installed in the following locations:
C:\Program Files (x86)\MSBuild\15.0
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild

And I have the .Net framework 4.6.2 installed here: "C:\Windows\Microsoft.NET\Framework64\v4.0.30319"

Thanks!

Product: BuildMaster
Version: 5.7.2



Update 1:

Responding to @emiel-koning, I tried to specify $MSBuildToolsPath in the build step using:

set $MSBuildToolsPath = C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin;

But I get this error:
error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. Also, tried to find "WebApplications\Microsoft.WebApplication.targets" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe.Config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths.

Update 2:

Could I be missing something installed on my build server? I installed Visual Studio Build Tools which gave me the MSBuild 15.0 but not the WebApplication.targets file from the error above



SOLUTION
I fix my issues by also installing "Web development build tools" component. I also set the $MSBuildToolsPath at the server level until I can roll out the new MSBuild globally. enter image description here

coshea34
  • 63
  • 2
  • 6

2 Answers2

1

In general, this is handled by the ToolsVersion attribute of the project file. This should be what is used if the below configuration is not specified.

In BuildMaster specifically, you can override this value per-server on the Administration > BuildMaster Extensions > Windows SDK > Configuration tab. Click on $MSBuildToolsPath (and optionally override at a specific scope) with a value of C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin

Response to Updates #1 & #2:

First, don't set that variable in the plan itself (otherwise you'd have to set it in every plan). Set it in the manner I described above. Personally, I always specify its value at the server level since each server may have it installed in a different location.

As for Microsoft.WebApplication.targets, I think the only supported method of building web application projects is to have Visual Studio installed on the build server; though in the past I've just copied the targets from my local installation (C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications) into the path that MSBuild is expecting them to be.

Community
  • 1
  • 1
John Rasch
  • 62,489
  • 19
  • 106
  • 139
  • Note that the `ToolsVersion` attribute only helps discovering installed toolsets, not the MSBuild version itself. this is crucial for msbuild 15+ projects relying on new file syntax and capabilities - e.g. .NET Core projects. – Martin Ullrich Jul 12 '17 at 20:44
  • Interesting, that would explain why it's rarely worked for me (and I always end up specifying which one to use). From the [VS MSBuild docs](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-toolset-toolsversion): "When a ToolsVersion value is defined in a project file, MSBuild uses that value to determine the values of the Toolset properties that are available to the project. One Toolset property is $(MSBuildToolsPath), which specifies the path of the .NET Framework tools." – John Rasch Jul 12 '17 at 20:51
  • `$(MSBuildToolsPath)` also doesn't help if an "sdk-style" project was loaded by msbuild 14 or even msbuild 4, since it couldn't even parse the project file (``). Also, the `ToolsVersion` property is now optional on projects in MSBuild 15. – Martin Ullrich Jul 12 '17 at 21:07
  • Though it might just work for the OP if the projects are still compatible with MSBuild 14 – Martin Ullrich Jul 12 '17 at 21:07
  • I have the ToolsVersion set to 15.0 in my project file. Here is the excerpt: ` ` – coshea34 Jul 13 '17 at 13:59
1

Can you use $MSBuildToolsPath to specify the correct path to MSBuild?

Emiel Koning
  • 4,039
  • 1
  • 16
  • 18