I wanted to try out a daily build of Roslyn to see the effect of a recent change to the C# compiler. I know how to do this for older .NET Framework projects, I'd add a reference to
Microsoft.Net.Compilers which ships its own copy of
csc.exe, however I wasn't sure how to do it for .NET Core projects, so I thought I do a quick write-up of what I found.
At the time of writing, when running this console app with the C# compiler that ships with .NET Core SDK
3.0.100 it prints...
In the latest master of Roslyn I expect this not to be the case.
Add Reference to Microsoft.Net.Compilers.Toolset
It turns out there is a package that does exactly what I need, it includes its own copy of
csc and importantly for .NET Core as well as .NET Framework (unlike
Microsoft.Net.Compilers). Here it is:
There are daily builds of this on the Roslyn myget feed. To add it quickly, you can run this command:
dotnet add package Microsoft.Net.Compilers.Toolset --version 3.5.0-beta1-19530-09 --source https://dotnet.myget.org/F/roslyn/api/v3/index.json
Now we should be good to go, let's run our app again...