MSBuild jobs failing with C# Compilation errors

Still need help?

The Atlassian Community is here for you.

Ask the community


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:

  1. Use Visual Studio 2015 to build your project
  2. 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

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.