0

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.
Jonesome Reinstate Monica
  • 6,618
  • 11
  • 65
  • 112
  • Possible duplicate of [I am getting an error when using the Null-conditional Operator: Syntax error, ':' expected](http://stackoverflow.com/questions/38059149/i-am-getting-an-error-when-using-the-null-conditional-operator-syntax-error) – Khalil Khalaf Sep 21 '16 at 20:29
  • "_fails to compile_" What is the error? – Khalil Khalaf Sep 21 '16 at 20:30
  • 1
    @FirstStep I think it is not quite a dupe. It is similar, but that other thread mentions what should be the solve, without saying what to actually do. (I don't magically know which msbuild on my system is the roslyn compiler.) Apologies, I should have the compile error but don't have access to the build log at the moment. – Jonesome Reinstate Monica Sep 21 '16 at 20:33

1 Answers1

1

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

Community
  • 1
  • 1
Jacob
  • 616
  • 1
  • 4
  • 13