We have Team Foundation Server (TFS) 2015 installed on-premises. We would like to use Visual Studio 2017 to take advantage of the latest C# language features. We are not ready to upgrade to TFS 2017. What are the steps required to allow the latest C# language features to build in TFS 2015?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I didn't follow these steps exactly, but based on what I have learned, I think they would have worked:
- Install Visual Studio 2017 Build Tools on the XAML Build Configuration server
- Add these lines to the TFSBuildServiceHost.exe.config file:
<configSections>
<section name="msbuildToolsets" type="Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" requirePermission="false" />
</configSections>
<msbuildToolsets>
<toolset toolsVersion="15.0">
<property name="MSBuildToolsPath" value="C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin" />
</toolset>
<toolset toolsVersion="latest">
<property name="MSBuildToolsPath" value="C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin" />
</toolset>
</msbuildToolsets>
C:\Program Files\Microsoft Team Foundation Server 14.0\Tools\TFSBuildServiceHost.exe.config
(I never would have figure that out without this post. Thank you jonesy2488!)
- Restart the XAML Build Configuration service.
- Change the XAML Build Process Template to include the ToolVersion="15.0" parameter:
<mtba:RunMSBuild DisplayName="Run MSBuild" OutputLocation="[OutputLocation]" CleanBuild="[CleanBuild]" CommandLineArguments="[String.Format("/p:SkipInvalidConfigurations=true {0}", AdvancedBuildSettings.GetValue(Of String)("MSBuildArguments", String.Empty))]" ConfigurationsToBuild="[ConfigurationsToBuild]" ProjectsToBuild="[ProjectsToBuild]" ToolVersion="15.0" ToolPlatform="[AdvancedBuildSettings.GetValue(Of String)("MSBuildPlatform", "Auto")]" RunCodeAnalysis="[AdvancedBuildSettings.GetValue(Of String)("RunCodeAnalysis", "AsConfigured")]" />
回答2:
Just install latest version of Microsoft.Net.Compilers nugget package
https://www.nuget.org/packages/Microsoft.Net.Compilers >> .Net Compilers package. Referencing this package will cause the project to be built using the specific version of the C# and Visual Basic compilers contained in the package, as opposed to any system installed version.
This package can be used to compile code targeting any platform, but can only be run using the desktop .NET 4.6+ Full Framework.