Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS 2015 build template cannot build C#7 features

We use TFS 2015 as our build server for continuous integration with xaml build definitions. TfvcTemplate12.xaml is the build process template that we are using. When visual studio 2015 came out, we updated out build templates by setting the MSBuild arguments to

/p:VisualStudioVersion=14.0

After doing so, the build server was successfully able to build projects with C# 6 features. Now that Visual Studio 2017 has been released, along with C# 7, I thought I could simply install visual studio 2017 on the build server and update the MSBuild argument to use v15.0. This doesn't seem to work, the build agent still uses MSBuild v14.0 which cannot compile new features in C# 7. In a further attempt, I tried setting the tools version to 15.0

/tv:15.0

But that didn't work either. The build fails with a very generic error message and nothing useful to help me figure this out. Has anyone gotten this to work?

Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException)
Exception Stack Trace:    at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
like image 261
darrunategui Avatar asked Mar 27 '17 22:03

darrunategui


3 Answers

As many of the suggested answers mentioned, using one of the default XAML build process templates to use MSBuild v15 is simply not possible without manually modifying the template itself.

I was able to successfully get this working by modifying DefaultTemplate.11.1.xaml and looking for the MSBuild activity. There, you need to manually set the ToolPath property to the filename where MSBuild v15 is installed.

ToolPath="C:\Program Files (x86)\Visual Studio\2017\<more path>\msbuid.exe"

I can guarantee this will work for building projects. Not so sure about executing test cases though. Others have mentioned that it won't work but I haven't actually tried it myself.

Since writing this question I have started migrating away from XAML builds to the new build system which offers much more customization in the build process and is actually much simpler to use/understand if you read the documentation.

https://learn.microsoft.com/en-us/vsts/build-release/

like image 154
darrunategui Avatar answered Oct 23 '22 20:10

darrunategui


MSBuild V14.0 wouldn't know what v15.0 is.

You'll need to install Visual Studio 2017 build tools.

like image 4
Paulo Morgado Avatar answered Oct 23 '22 20:10

Paulo Morgado


I found a similar issue,I tried to build VS 2017 projects on TFS 2013,finally I solved the issue.

The solution is to use the old build process template (XAML) like the default build template from TFS 2012, set the ToolPath in the template to point to the path of MsBuild.exe on TFS 2013. I think this solution should also be working for TFS 2015.

like image 1
Simon Liu Avatar answered Oct 23 '22 21:10

Simon Liu