35

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<System.String>
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)'.'
jessehouwing
  • 87,636
  • 19
  • 214
  • 286
quadroid
  • 7,621
  • 5
  • 41
  • 71

4 Answers4

43

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

Community
  • 1
  • 1
Simon_Weaver
  • 120,240
  • 73
  • 577
  • 618
  • Seems to work for me as well, had exactly the same problem,but we installed the microsoft build tools (2015) instead of visual studio 2015. Setting the ToolPath in the xaml seems to be the missing step. Thanks! – Pieterjan Spoelders Jun 15 '16 at 14:57
  • 1
    TfvcTemplate.12.xaml does not contain ToolPath...where is it? – ShaneKm Jan 23 '17 at 21:22
  • Sorry I don't even begin to try to understand these xaml files. However if you have the time you may want to migrate away from the xaml files to the new build process in TFS 2015 and later. Easier to make changes yourself without having to learn the crazy xaml. https://www.visualstudio.com/en-us/docs/build/define/create – Simon_Weaver Jan 23 '17 at 21:26
  • @Simon_Weaver: You saved me my hair. – Baahubali Jun 08 '17 at 06:18
  • You're a legend! Thanks Simon – Neville Jun 14 '17 at 23:38
  • Or just fix it in one place once and for all: https://stackoverflow.com/a/51050214/792348 – Christian Jul 16 '18 at 07:53
14

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

Siva palla
  • 626
  • 5
  • 12
  • If I change the ToolPath in the build template to MSBuild, the Build works but I get the following exception: TF900546: An unexpected error occurred while running the RunTests activity: ''codeBase' cannot be an empty string (""). Parameter name: codeBase'. – quadroid Jul 02 '15 at 11:28
  • are running with codecoverage .If yes,can you disable and test once – Siva palla Jul 02 '15 at 12:06
  • disabling the code coverage did help. now I get the following error Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.Utilities, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. – quadroid Jul 02 '15 at 12:17
  • Does this dll present in build controller.If yes register in GAC – Siva palla Jul 02 '15 at 12:37
  • Yes the file is present, Registering it in the GAC does not help – quadroid Jul 02 '15 at 13:01
  • Is Visual Studio 2012 also installed? The build server will try to find the location of `vstest.console.exe` and will look under the Visual Studio 2012 folder for it. – jessehouwing Jul 05 '15 at 17:57
  • @jessehouwingas i wrote, visual studio 2012 is installed aswell – quadroid Jul 09 '15 at 20:06
  • i changed the toolspath in the msbuild activity and the build runs fine with code analysis disabled. When i enable the code analysis the build runs forever and does not complete. Dont understand whats happening when i enable the code analysis – last-Programmer Jul 24 '15 at 16:49
  • This is actually in TWO places - see my answer. Very annoying! – Simon_Weaver Aug 28 '15 at 02:33
  • For 2015 you should end the path in `bin` and not include `msbuild` at the end (perhaps it doesn't matter either way but that's what worked for me) – Simon_Weaver Aug 28 '15 at 19:58
  • 9
    The `Microsoft.TeamFoundation.Build.Activities.RunMSBuild` activity doesn't have a `ToolPath` property - only a `ToolVersion` property, which doesn't seem to change anything as the original question mentions. This activity type seems to be simpler than the `Microsoft.TeamFoundation.Build.Workflow.Activities.MSBuild` activity. it abstracts a lot of the detail away. – Andy McCluggage Sep 08 '15 at 08:10
5

See answer by Marson.

Using the TfvcTemplate.12.xaml build process template with the /tv:14.0 Build argument worked for me.

Community
  • 1
  • 1
gReX
  • 1,419
  • 1
  • 18
  • 32
  • this will not work for TFS 2012 as TfvcTemplate.12.xaml is only for TFS 2013+ – Lareau Feb 03 '16 at 15:04
  • @Lareau I'm on TFS 2013 Update 4. Thanks for pointing this out. I think on TFS 2012 the accepted answer should work. For 2013+ see also my answer http://stackoverflow.com/a/33238651/1196586 – gReX Feb 03 '16 at 16:42
0

use msbuild aruguments /p:VisualStudioVersion=14.0

Siva palla
  • 626
  • 5
  • 12