Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BuildActivity ignores ToolsVersion

Tags:

msbuild

tfs

I have a Continuous Integration Build Running on a BuildAgent which I can not get working properly. I recently changed our codebase to C# 6.0 and changed the projects to ToolsVersion 14.

I did install Visual Studio 2015 on the Build Server (TFS 2012). If I do now check in the C# 6.0 code the build fails on the first project ("$" is unexpected or something")

The BuildTemplate is "DefaultTemplate.11.1" If I check the log files the build calls the wrong csc.exe (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Csc.exe)

if I do start the MSBuild/14.0/Bin/MSBuild executable with the project without any switches the Build succeeds. Why does the TFS BuildAgent not use the ToolsVersion and how can I get TFS 2012 to build my Visual Studio 2015 solution

If I add the MSBuildArgument /tv:14.0 it still fails. As it calls th Version 12 of MSBuild which is part of the .NET 4.6 RC Framework which ships with Visual Studio 2015.

Changing the ToolsPath of the MSBuild Activity does get the Build working but spits bullets if I try to run my UnitTest. I get aMissing dlls "Microsoft.VisualStudio.TestPlatform.Utilities.dll" exception. (VS2012 is installed as well on the Build Server).

UPDATE: I do now get a different error with my unit tests:

TF900548: An error occurred publishing the Visual Studio test results. Details: 'Method not found: 'System.Collections.Generic.IEnumerable&lt;System.String&gt; Microsoft.VisualStudio.TestPlatform.Utilities.InferSettingsHelper.MergeRunSettingsAndFindCompatibleSources(Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture ByRef,  Microsoft.VisualStudio.TestPlatform.ObjectModel.FrameworkVersion  ByRef, System.String, System.String,  System.Collections.Generic.IDictionary`2<System.String,System.Collections.Generic.KeyValuePair`2<Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture,Microsoft.VisualStudio.TestPlatform.ObjectModel.FrameworkVersion>>,  System.Xml.XPath.IXPathNavigable, System.String ByRef)'.' 
like image 411
quadroid Avatar asked Jul 02 '15 09:07

quadroid


2 Answers

For those of us not living inside build templates every day here's the steps that got it working for me:

First find the template associated with your build (if you already know where to find it skip a couple steps).

  • Just right click the build definition and select Edit build definition

  • Select the Process tab and you'll see the name of the template (quite likely to be DefaultTemplate if you haven't customized it). On the far right click Show details to see the path for the template.

enter image description here

  • Go to the Home tab under Team explorer and click Source control explorer

enter image description here

  • Find the template file and double click to edit it. It should come up in a graphical view like this. Scroll till you find Run MSBuild for Project

enter image description here

  • Click on this item which will immediately bring up properties

enter image description here

  • Click on the little icon on the right - don't try and type it in because it'll probably explode and crash Visual Studio.

  • Enter IN QUOTES the following "C:\Program Files (x86)\MSBuild\14.0\bin"

enter image description here

NOW FOR THE MOST IMPORTANT PART

For me the Run MSBuild for Project was in TWO places.

So I just repeated the above steps in both places, and then after I checked in the .xaml file my build FINALLY worked fine.

You may need to recycle the agent / controller from within the TFS tool.

enter image description here

like image 109
Simon_Weaver Avatar answered Sep 29 '22 17:09

Simon_Weaver


Edit template change msbuild activity ToolPath to "MSBuild/14.0/Bin/MSBuild"

like image 33
Siva palla Avatar answered Sep 29 '22 15:09

Siva palla