2
votes

I have a TFSBuild 2013 server that we are trying to now build UWP projects with, but we cannot seem to make it use the correct MSBuild version.

Symptoms:

When building the UWP projects, we get lots of errors like this: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets (283): A numeric comparison was attempted on "10.0.11000.0" that evaluates to "10.0.11000.0" instead of a number, in condition "'$(TargetPlatformVersion)' >= '10.0.11000.0'".

Many reports abound for this error, all telling you to ensure that TFS Build is using the correct version of the MSBuild. And herein lies the issue. We cannot seem to make the build server use the correct version.

Here is what we have tried (build definitions are using TfvcTemplate.12.xaml template):

  • Installing 2015 build tools (update 3) on the build server
  • Installing VS2015 on the build server (Yuck)
  • Various combinations of MSBuild parameters in the build definition. (/tv:14.0 & /p:VisualStudioVersion=14.0)
  • Inclusion of Microsoft.Net.Compilers nuget package
  • Editing the TfvcTemplate.12.xaml template and setting "Run MSBuild" step to set "ToolsVersion" to "14.0". (Note, there is no "ToolsPath" setting in this version of the template, so I cant do that).
  • Setting ToolsVersion="14.0" in every .csproj file

No matter what we change, we cannot get the Build Agent to use the 14.0 version of MSBuild.

Strangely, nuget seems to find the correct version when doing the package restore. In the logs we see this when running the nuget.exe restore command: MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.

But further down in the logs, where all the errors start we see this (note: wrong tools version): C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe /nologo /noconsolelogger "C:\Builds..." [SNIP]

Any help or suggestions gratefully received - I'm at my wits end :)

2
Are you able to build your project with MSBuild command line manually on your build agent machine? Do you specify the MSBuild argument /p:AppxBundlePlatforms="$(BuildPlatform)" /p:AppxPackageDir="$(Build.BinariesDirectory)\AppxPackages\\" /p:AppxBundle=Always in your build definition?Cece Dong - MSFT
Yes, building the solution using VS2015 on the server works fine.MercifulGiraffe
We would be happy if we could just force TFSBuild to always use the 14 version of MSBuild. Can we force it somehow to do that by default?MercifulGiraffe

2 Answers

1
votes

I finally gave up trying to make this behave with configuration, but managed to get this working on the build machine by hacking the registry.

I changed the following registry keys:

HKLM\SOFTWARE\Wow6432Node\Microsoft\MSBuild\12.0\MSBuildOverrideTasksPath
HKLM\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\12.0\MSBuildToolsPath

In both cases, I changed the value

from:

C:\Program Files (x86)\MSBuild\12.0\bin\

to:

C:\Program Files (x86)\MSBuild\14.0\bin\

Disclaimer: I don't know what other affects this will have, but its got our builds using the correct MSBuild version, and is limited in scope to the build server.

0
votes

Editing the TfvcTemplate.12.xaml template and setting "Run MSBuild" step to set "ToolsVersion" to "14.0".

This will work if you also add the following piece in the MSBuild 12.0 config file (as described here)

<msbuildToolsets>
    <toolset toolsVersion="14.0">
        <property name="MSBuildToolsPath" value="C:\Program Files (x86)\MSBuild\14.0\Bin\" />
    </toolset>
</msbuildToolsets>

Please note there is also amd64 folder in the MSbuild\bin directory which has its own config file