And old project I've upgraded from .NET 4.6.1 to 4.7.2 contains a reference to Microsoft.Bcl.Build
and another had Microsoft.Net.Compilers
. Microsoft.Bcl.Build
is very obsolete (2014), so we can ignore that one.
I read that Microsoft.Net.Compilers
was deprecated for some time, and used to be a dependency of Microsoft.CodeDom.Providers.DotNetCompilerPlatform
. Then Microsoft.CodeDom.Providers.DotNetCompilerPlatform
was updated in 2.x to no longer have Microsoft.Net.Compilers
as a dependency.
Now, it seems things have flipped back, because Microsoft.CodeDom.Providers.DotNetCompilerPlatform
hasn't been updated since 2018, while Microsoft.Net.Compilers
was updated only 22 days ago with support for C# 8! The Microsoft.Net.Compilers
page (https://github.com/dotnet/roslyn/blob/master/docs/wiki/NuGet-packages.md) mentions the Microsoft.CodeDom.Providers.DotNetCompilerPlatform
package at the bottom, but doesn't really explain their relationship or why it hasn't been updated in years. It's strange that the other one had this one as a dependency, then removed it, and now isn't being maintained.
Other advise is, System.Net.Compilers
is deprecated, use System.Net.Compilers.ToolSet
, and still other advise is "don't use either" and neither are meant for general consumption and won't be available after VS 16.5: https://stackoverflow.com/a/60623906/88409.
These packages both seem to override the build system, so are they mutually exclusive? I do get an error when both are installed (explained below), but it may not necessarily be caused by mutual exclusivity.
Additional Info
When targeting .NET 4.7.2, with neither package installed, I get an error on MVC cshtml pages that says:
The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Home".
Installing System.Net.Compilers
does NOT solve it, although the publish succeeds. Meanwhile, installing Microsoft.CodeDom.Providers.DotNetCompilerPlatform
by itself does fix the error. The one thing different the latter does is it adds a section to the web config for system.codedom/compilers/compiler for language="c#".
Even though both install fine individually, if I have both packages installed, the publish operation fails with an error saying "Microsoft.Net.Compilers is only supported on MSBuild v16.3", so it almost seems like Microsoft.CodeDom.Providers.DotNetCompilerPlatform
is forcing use of (or is based on?) an earlier version of MSBuild? The Project file's ToolsVersion attribute is 14 (although setting it to anything else doesn't seem to have any effect. I set it to 215 and it didn't complain, for example. This is all very confusing.