空条件运算符无法在MSBUILD中编译

时间:2016-09-21 20:08:32

标签: c# msbuild

我们有VS 2015更新2,并发现以下语法在VS中编译正常,但在使用MSBUILD进行编译时失败:

如下所述:https://msdn.microsoft.com/en-us/library/dn986595.aspx

此语法失败:

int? length = customers?.Length;

出现此问题的系统已安装VS 2015更新2和.NET 4.6.1。 从MSBUILD(这是构建系统使用的......)构建时,我们只有这个问题。这是控制台输出,显示我们如何运行msbuild:

Executing external process: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
Parameters: C:\develop\<our app>\msbuild_project.xml /p:DefineConstants="Compiled_for_Windows_Service_Case_12345" /m
Output from C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
Microsoft (R) Build Engine version 4.6.1038.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

1 个答案:

答案 0 :(得分:1)

您需要使用更高版本的MSBuild.exe。有关示例,请参阅:

How to build .NET 4.6 Framework app without Visual Studio installed?

C:\ Program Files(x86)\ MSBuild \ 14.0 \ Bin \ MsBuild.exe MySolution.sln