Build VS2017 project with TFS 2012 build server

2019-01-28 05:44发布

问题:

We have an on-premise TFS 2012 server and build server. We are in the process of upgrading to VS and TFS 2017. At the moment, there is the request to set up another build server that will allow us to build new 2017 projects from the existing TFS server. I create a new build server and installed TFS 2012 build services on it as well as VS2017. I created a new build definition but it fails to compile and errors show things like the syntax changes for 2017 that are invalid in 2012. How do I tell configure this to build the project against the installed VS2017?

回答1:

Old Visual Studio versions installed msbuild into C:\Program Files (x86)\MSBuild\<version>\bin and apparently the RunMSBuild activity used the ToolVersion + the ToolArchitecture to calculate this path.

VS 2017 instead installs it C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin and the RunMSBuild can't calculate the proper path anymore. You can not use the old DefaultTemplate11.1xaml to integrate with VS2017.

To make this work, you could try to modify the TFSBuildServiceHost.exe.config and you must have a version of VS 2013 or VS 2015 installed on the build server in order for this to work. More detail step please follow Jonesy2488's answer in this link:How to get VS 2017 working with TFS 2017 XAML Builds


Moreover, XAML Build are deprecated in TFS 2017 and will not be available in tge next version of TFS(2018). VSTS already no longer supports them.

I'm looking for the hosted XAML build controller. Where did it go?

The hosted XAML build controller is no longer supported. Accounts created on or after April 2016 do not have access to it. We plan to remove the hosted XAML build controller from all accounts, possibly as soon as March 2017.

Source

Since you are going to upgrade and use TFS2017. Highly recommend you to convert your builds to vNext Build to access some new technology and support. For more please refer Why Should I Leave XAML Builds?



回答2:

Thanks to this post, I was able to use TFS 2012 continuous integration with build server building C# 6 syntax using Visual studio 2017. Hopefully this will save the next person some time in trying to figure this out.

Here are the list of things I have changed in order to get TFS 2012 to build c# 6 syntax. On the machine with the build agent, install vs 2017 enterprise, on the installation setup page, make sure MS build is selected

Edit the Build definition and make sure the MSBuild Argument is /tv:15.0 /p:GenerateBuildInfoConfigFile=false /p:VisualStudioVersion=15.0

Check the template your build definition is using and modify it by going to the source control explorer and going into the team project and undert BuildProcessTemplate, it should have the .xaml file, modify it by double clicking on it

There should be 2 actions that say Run MSBuild for Project. You need to change both of their toolpath property to point to the msbuild.exe parent folder on the build server. In my case, the build server is a 32 bit machine so the path to the Bin folder doesn't have (x86) next to Program Files, you need to check your build server to enter the correct path here. After you have made the changes, you need to save the xaml and check it in.



标签: c# .net tfs build