When C# 6 arrived I just referenced the Microsoft.Net.Compilers NuGet package and TFS builds of C# 6 features started working right away without having to install additional dependencies on the build machine.
Now that C# 7 is here is there an equivalent NuGet package that can do the same thing? (or is this not really a recommended way of adopting C# 7?)
The description for the Microsoft.Net.Compilers package does say that it "causes the project to be built using the specific version of the C# [...] compilers contained in the package", however I can't find out what the corresponding C# compiler version is for a given NuGet package. I've tried adding the latest stable version (1.3.2) however C# 7 features aren't compiling (and this package is ~6 months old anyway, so I wouldn't really have expected it to work)
A brief overview would be appreciated. Show activity on this post. The point of the Microsoft.Net.Compilers package is that the compilers distributed with that package will be used for compiling your project, rather than the compiler that comes with .NET Framework or with Visual Studio.
There is a successor package named Microsoft.Net.Compilers.Toolset. This package has much the same functionality as Microsoft.Net.Compilers but works with both .NET Desktop and .NET Core MSBuild instances. Even so Microsoft.Net.Compilers.Toolset is not meant for general consumption.
This section describes the options interpreted by the C# compiler. Options are grouped into separate articles based on what they control, for example, language features, code generation, and output. Use the table of contents to navigate amongst them. There are two different ways to set compiler options in .NET projects:
The .NET Framework 4.5 and later versions are backward-compatible with apps that were built with earlier versions of the .NET Framework. In other words, apps and components built with previous versions will work without modification on the .NET Framework 4.5 and later versions.
An updated Microsoft.Net.Compilers package was published the same week that VS2017 was released.
See the Roslyn documentation about what package version corresponds to which C# language version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With