7

I encounered this problem when I've open one of my projects for the first time on Visual Studio 2019. This was a project that I've created about three years ago and demand me just a few changes a year.

The first time I've tried to compile this project on Visual Studio 2019 I received an error related to csc.exe file, and as I've had been this error before, I've reinstaled compilers componente at Nuget Package Manager, as I did in previous times successfully.

After that, I got the error "Microsoft.Net.Compilers is only supported on MSBuild v16.3 and above".

I found out some solutions on Microsoft Developer Community recommending to open and edit the file: "packages\Microsoft.Net.Compilers.3.4.0\build\Microsoft.Net.Compilers.props", but it seens like wierd to me.

Marcelo Sader
  • 331
  • 4
  • 12
  • 1
    can you post the output of MSBuild or your IDE when trying to build? – Minijack Feb 05 '20 at 00:26
  • No I don't. After fixed it, I could not to reproduce the error any more. I will try to compile other projects in order to try to get the same error again. – Marcelo Sader Feb 05 '20 at 01:07

3 Answers3

10

EDIT: As this new answer to another question states it is unlikely that Microsoft.Net.Compilers is necessary to have in your project. Read through that answer to make sure you actually need it at all. If you don't, removing Microsoft.Net.Compilers should resolve your issue. If you still need its limited functionality or if you have a problem after uninstalling it, read on for the original answer:


I had this problem after upgrading to .NET framework 4.7.2, and could not upgrade to the suggested beta of Microsoft.Net.Compilers as it didn't seem to be available.

It should be noted that Microsoft.Net.Compilers has been deprecated and migrating to Microsoft.Net.Compilers.Toolset is recommended.

To migrate, you can simply use Nuget to uninstall Microsoft.Net.Compilers and install Microsoft.Net.Compilers.Toolset.

The version number for both was the same for me, but this fixed the problem for me and I was able to build.

JackArbiter
  • 5,705
  • 2
  • 27
  • 34
8

Upgrade nuget package Microsoft.Net.Compilers to version 3.5.0-beta2-final and it should work.

deanwilliammills
  • 2,617
  • 2
  • 21
  • 27
6

After some hours trying to fix it, I just uninstall an reinstall two componentes latest stable versions, at the Nuget Package Manager:

  • Microsoft.CodeDom.Providers.DotNetCompilerPlataform v 2.0.1;

  • Microsoft.Net.Compilers v 3.4.0

Everything is working fine from now.

Marcelo Sader
  • 331
  • 4
  • 12
  • 1
    Great! Thanks for sharing your solution here, you could [Accept it as an Answer](https://stackoverflow.blog/2009/01/06/accept-your-own-answers/) , so it could help other community members who get the same issues and we could archive this thread, thanks. – LoLance Feb 13 '20 at 11:29
  • 1
    I had exactly the same error (VS2017 project moved to VS2019) - worked fine locally but hit that error when publishing. Running rebuild a couple of times in debug mode and release mode seems to have cleared it – gchq Feb 16 '20 at 16:13
  • 1
    Why do you need both? Aren't these both build systems, in which case only one or the other will be used? Microsoft.CodeDom.Providers.DotNetCompilerPlatform used to have Microsoft.Net.Compilers as a dependency, and then eliminated that dependency in version 2.0.1. However, v2.0.1 hasn't been updated since 2018, and now Microsoft.Net.Compilers seems to have been updated as recently as 22 days ago. So which one should be be using now? These seem like mutually exclusive packages, where one used to be the best choice, then the other, and now Microsoft.Net.Compilers is the latest and greatest again – Triynko Mar 12 '20 at 18:13
  • Hi @Triynko I really don't know, and to be honest, I couldn't investigate more deep because I had to go ahead with others tasks in order to go further with my project. Maybe if this problem happens again I have the opportunit to try to use just one of them. – Marcelo Sader Apr 01 '20 at 12:23