question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove Microsoft.Net.Compilers dependency

See original GitHub issue

The Umbraco 8 NuGet package includes a dependency on Microsoft.Net.Compilers (>= 2.10.0 && < 2.999999): https://github.com/umbraco/Umbraco-CMS/blob/178b1ccf40aa67815be77698a259b5db31ab9013/build/NuSpecs/UmbracoCms.nuspec#L33

As commented earlier (https://github.com/umbraco/Umbraco-CMS/issues/4493#issuecomment-489080794), this is not required as Microsoft.CodeDom.Providers.DotNetCompilerPlatform (>= 2.0.0) already includes the compiler binaries (for dynamic compilation of views): https://github.com/aspnet/RoslynCodeDomProvider#version-200.

Installing Microsoft.Net.Compilers replaces the built-in compiler that’s used when building the project and because of the version range, it’s not possible to update this to the latest version to make use of new C# features. It’s also slower than using the compiler Visual Studio ships with and version 2.10.0 is actually the same as the minimum required VS version for local development: https://our.umbraco.com/Documentation/Getting-Started/Setup/Requirements/#local-development.

Reproduction

Bug summary

Can’t use the latest C# features, as the compiler gets replaced by an out-of-date version because it’s included as a NuGet dependency.

Workaround

It’s possible to forcefully remove the package PM> Uninstall-Package Microsoft.Net.Compilers -Force (gives errors when updating Umbraco), remove the build-target from the project file (needs to be repeated after updating the package) or move code to a seperate library. This should however not be required…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ronaldbarendsecommented, Oct 1, 2019

PR is created, I’m going for that hacktoberfest/contrib-2019 label 😉

0reactions
ajaysadyaldoeacccommented, Oct 13, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Microsoft.Net.Compilers is only supported on MSBuild v16. ...
To migrate, you can simply use Nuget to uninstall Microsoft.Net.Compilers and install Microsoft.Net.Compilers.Toolset . The version number for ...
Read more >
dotnet remove package command - .NET CLI
The dotnet remove package command provides a convenient option to remove a NuGet package reference from a project.
Read more >
Remove the .NET runtime and SDK
The .NET Uninstall Tool ( dotnet-core-uninstall ) lets you remove .NET SDKs and runtimes from a system. A collection of options is available ......
Read more >
Remove unused references - Visual Studio (Windows)
Right click on a project name or dependencies node in Solution Explorer. · Select Remove Unused References. Remove Unused References command · The ......
Read more >
Microsoft.Net.Compilers is only supported on MSBuild v16. ...
The Microsoft.Net.Compilers package deliberately requires MSBuild 16.3. The MSBuild task included in this package relies on new MSBuild features ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found