MSBuild jobs failing with C# Compilation errors
Problem
When running a build using MSBuild from Visual Studio 2017, the build fails with the following Compilation errors in the Build Log:
My_Code.cs(123,73): error CS1525: Invalid expression term '.' [<build-working-directory>\dir\My_project.csproj]
My_Code.cs(123,74): error CS1003: Syntax error, ':' expected [<build-working-directory>\dir\My_project.csproj]
Diagnosis
Environment
- Windows
- Visual Studio 2017
Cause
The errors here are caused by Visual Studio 2017 compiling your code against an older version of the Microsoft.Net.Compilers
package.
Resolution
There are two possible resolutions for this issue:
- Use Visual Studio 2015 to build your project
- Ensure that you are running version 2.0.1 or greater of the
Microsoft.Net.Compilers
package
Sources
Throw expression causes compiler error CS1525
VS 2017 - New C# 7 feature for out parameters causes project not to build
Last modified on Dec 30, 2019
Powered by Confluence and Scroll Viewport.