A project I have been working on was upgraded from .NET Framework 4.6.2 to 4.7.2. On build, in a file that is not my code, I get the following error:

enter image description here

I also see the same error in the build tab of my project properties.

[2]

I'm at a loss- I've searched for the error and am coming up empty. Has anyone encountered and/or resolved this before?

5 Answers

Looks like after upgrading your build tool is changed from MSBUILD to Roslyn. Microsoft.Managed.Core.targets is Roslyn target file.

if you have following Nuget packages installed:

  • Microsoft.CodeDom.Providers.DotNetCompilerPlatform

  • Microsoft.Net.Compilers

Then possibly it's causing the issue. Upgrade the Microsoft.CodeDom.Providers.DotNetCompilerPlatform to 2.x and remove the second one. That should fix the issue.

7

Ran into the same error - a compatibility issue between Microsoft.Net.Compilers 2.x (vs2017) and 3.x (vs2019) - downgrading from v3 to v2 fixed the issue specifically on our build agents which only had VS2017. v3 requires VS 2019 or later per roslyn-analyzers release spec.

Per the related error Method 'System.String.GetPathsOfAllDirectoriesAbove' not found - VS2017 would not even open the CSPROJ which was a clue about compatibility.

VS 2017 - CSPROJ Option to Install Missing Features for Microsoft.Net.Compilers v3

enter image description here

VS 2017 - Installing Missing Features

enter image description here

This happned to me when I updated Microsoft.Net.Compilers in an old project. Removing Microsoft.Net.Compilers completely, and then updating Microsoft.CodeDom.Providers.DotNetCompilerPlatform resolved my problem.

This can also happen when trying to compile a VS2019 project with an older version of Visual Studio (e.g., on a build server or in Azure DevOps).

If, after applying the solution from answer , the error changes to

##[error]CSC(0,0): Error CS1617: Invalid option '8.0' for /langversion 

then this is likely the case. The solution is then to build with the right version of Visual Studio (2019).

This error usually comes when you upgrade the below libraries by nuget

Microsoft.CodeDom.Providers.DotNetCompilerPlatform

Microsoft.Net.Compilers

Guys, If your project is not loading due to this error. just go to that project location by explorer and delete the obj folder manually.

Then right-click on the project and RELOAD AGAIN.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy