Reputation: 6934
We have VS 2015 update 2, and find that the following syntax compiles fine within VS, but fails when using MSBUILD to compile:
As described here: https://msdn.microsoft.com/en-us/library/dn986595.aspx
This syntax fails:
int? length = customers?.Length;
The system having this problem has VS 2015 update 2, and .NET 4.6.1 installed. We only have the issue when building from MSBUILD (which is what the build system uses...). Here is the console output showing how we run 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.
Upvotes: 0
Views: 2460
Reputation: 746
You need to use a later version of MSBuild.exe. For an example, see:
How to build .NET 4.6 Framework app without Visual Studio installed?
C:\Program Files (x86)\MSBuild\14.0\Bin\MsBuild.exe MySolution.sln
Upvotes: 1