Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
#7713: Dynamic C# Compilation, Static and Dynamic Razor Compilation with Roslyn (1.10.x) #8103
The PR looks pretty huge, but most of the changes are repetitive across projects. Let's see what we started from, what we wanted to achieve and how we did it.
Important: If you're using MSBuild directly, make sure that your PATH variable contains the path to the latest available MSBuild, as it needs a fairly recent version. If you have Visual Studio 2017 installed, then it's usually
What do we want?
A step in the right direction
An earlier iteration of these changes was already merged to 1.10.x and dev. It used two NuGet packages:
The problem with this was an "integration boom", where the configuration for Dynamic Compilation and Static Razor Compilation collided: The latter uses the ASP.NET Compiler, which (due to the configuration necessary for Razor IntelliSense) by default is looking for Roslyn in the extension's bin folder. However, Roslyn was not there (it was only included for Orchard.Web, because that's the starting point of Dynamic Compilation), because it didn't make sense to include ~16 MBs of files for every extension (a lot of compile-time I/O and deployment packages get bloated, so it would be a mess). The issue was that the DotNetCompilerPlatform package did not have a configuration option to define the path to the Roslyn files. I submitted an issue then a PR to fix that, but it was not accepted, then some time later the package's developers implemented it a bit differently (and their solution is actually better). After that we just needed a new release for the package (which took quite some time), so let's jump back to present time...
What changed this time?
Version 2.0.0 of the DotNetCompilerPlatform was shipped and now it actually includes the Roslyn package (version 2.8.2). This means that C# 7.3 is supported (but there's already a newer release - 2.9.0 - that improves C# 7.3 compilation).
So the changes in the PR are the following:
If this PR is accepted and merged into 1.10.x, then 1.10.x needs to be merged into dev. Then the remaining modules (those that only included in dev) need to be upgraded the same way as these ones.
All the csproj and web.config files are configured to always use the latest available C# version. This can mean different things depending on whether you want to use Dynamic Compilation or not:
The latter also means that theoretically, you can use an earlier version of Visual Studio and still be able to use recent language versions, e.g. Visual Studio 2015 (and thus the static C# compilation) is limited to C# 6, but Dynamic Compilation can currently handle everything up to 7.3. I haven't tested this, though.
So upgrading this pipeline is really just upgrading the Microsoft.CodeDom.Providers.DotNetCompilerPlatform package and its usage to the new version (which is basically a search and replace in the packages.config, web.config and csproj files).