Using custom version of Roslyn - oleg-shilo/cs-script.net-framework GitHub Wiki

The CS-Script NuGet package targeting .NET v4.6 contains Roslyn assemblies the script engine relies when compiling scripts with syntax C# 6.0. However in some cases (.NET Core) you may want to use an alternative version of Roslyn. It is easy because CS-Script assembly deliberately compiled against non-version specific Roslyn assemblies. Meaning that you can use CS-Script with any version of Roslyn NuGet package providing it has the same interface CS-Script was built and tested against.

In order to allow no interference between CS-Script prefered Roslyn assemblies and the assemblies of your Roslyn package CS-Script is packed in the "raw" package CS-Script.lib containing only a single CS-Script assembly (CSScriptLibrary.dll) and no dependencies at all. Thus you can add any Roslyn (or Mono) packaged of your choice.

PM> Install-Package CS-Script.lib

Thus in an experimental project it was possible to use CS-Script v3.18.1.0 version that was built against Roslyn v1.2 with Microsoft.Net.Compilers v1.3.2 NuGet package without any problems.

The minimal set of Rolyn assemblies that CS-Script (at least for v3.18.1) loads at runtime needs to be present in presented below:

Microsoft.CodeAnalysis.CSharp.dll
Microsoft.CodeAnalysis.CSharp.Scripting.dll
Microsoft.CodeAnalysis.dll
Microsoft.CodeAnalysis.Scripting.dll
System.IO.FileSystem.dll
System.IO.FileSystem.Primitives.dll
System.Reflection.Metadata.dll