如何升级的MSBuild到C#6? [英] How to upgrade msbuild to C# 6?
问题描述
我想用C#6在我的项目(空传播,其他功能)。
我已经在我的电脑上安装了VS 2015年和它出色的作品,并建立测试代码像
VAR用户=新SingleUserModel(); //所有模型字段为空
VAR测试= user.User .Avatar [嗒嗒]?;
但是,当我把我的项目回购和CI开始建造它,构建失败,因为不支持的?
。
我已经安装了CI服务器上VS2015太多,但像looke它不使用它。
我能做些什么
CI - CruiseControl的.NET
与构建C:?\Windows\Microsoft。 NET\Framework\v4.0.30319\MSBuild.exe
请确保你打电话
<预类=郎无prettyprint-覆盖>
C:\Program文件(x86)\MSBuild\14.0\Bin \MsBuild.exe
这是的MSBuild的版本附带的Visual Studio 2015年和调用C#编译器能够理解这一点。您可以通过安装Visual Studio 2015任何版本或安装独立的微软构建工具2015年。
添加到的following的NuGet包也将强制使用新的编译器的:
<预类=郎无prettyprint-覆盖>
安装封装Microsoft.Net.Compilers
I want to use C# 6 in my project (null propagation, other features).
I've installed VS 2015 on my PC and it works brilliantly and builds test code like
var user = new SingleUserModel(); //all model fields are null
var test = user.User?.Avatar?["blah"];
But when I push my project to the repo and CI starts to build it, build fails because of unsupported ?
.
I've installed VS2015 on CI server too but looke like it doesn't use it. What can I do?
CI - CruiseControl .NET
Builds with C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
Make sure you call:
C:\Program Files (x86)\MSBuild\14.0\Bin\MsBuild.exe
That's the version of MsBuild that ships with Visual Studio 2015 and calls the C# compiler that understands this. You can get this version of MsBuild on your system by installing any edition of Visual Studio 2015 or by installing the stand-alone Microsoft Build Tools 2015.
Adding a reference to the following NuGet package will also force use of the new compiler:
Install-Package Microsoft.Net.Compilers
这篇关于如何升级的MSBuild到C#6?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!