How do I configure VS2015 to support Rosyln C# scripting? Scripting support was not part of the VS2015 RTM, so I've installed packages from roslyn-nightly and dotnet-core but I can't get past component version mismatches.
1 – My goal is to embed C# expressions inside configuration-related scripts used by my program. I am replacing an old VB6 program that used VBA for the same purpose. That solution worked really, really well and made the old program quite flexible.
2 – I am using VS2015 RTM, the Community version. VS2013 Professional is also installed on my PC. The PC is running Win7 SP1.
3 – I've installed various packages from roslyn-nightly and dotnet-core. I started by installing a bare minimum, but based on error messages and advice from various people I have tried many variations of packages. I admit I really have no idea which packages are necessary. Determining which packages are necessary has been my main goal, but perhaps the issue lies elsewhere.
4 – I followed the instructions at the URL below.
https://github.com/dotnet/roslyn#build-tools-that-understand-c-and-visual-basic
That includes a link here:
https://github.com/dotnet/roslyn/wiki/Getting-Started-on-Visual-Studio-2015
5 – I am using the following code to test whether or not I've got VS configured properly to support scripting:
using System;
using Microsoft.CodeAnalysis.Scripting.CSharp;
namespace RoslynScriptingTest {
class Program {
static void Main(string[] args) {
var script = CSharpScript.Create("1 + 2");
var fn = script.CreateDelegate();
var value = fn();
Console.WriteLine("value={0}", value.ToString());
}
}
}
I lifted code from one of the Roslyn test files then put it in a Console project and added the Console.WriteLine call.
6 – I get various warning messages when I build the project. The specific messages vary based on which packages are installed, but they always include messages about missing files that appear to be caused by version mismatches. Here is an example from the current incantation of the project which includes most (if not all) of the packages available at roslyn-nightly and several from dotnet-core. I do not know how to efficiently communicate which packages I have installed given there are so many (43).
Warning, MissingAnalyzerReference, Analyzer assembly 'C:\Dev\vsProjects\Experiments\RoslynScriptingTest\packages\Microsoft.AnalyzerPowerPack.1.1.0-beta1-20150726-01\analyzers\dotnet\cs\Microsoft.AnalyzerPowerPack.Common.dll' depends on 'Microsoft.CodeAnalysis.Workspaces, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' but it was not found. Analyzers may not run correctly.
7 – At runtime, I get a TypeInitializationException on the CSharpScript.Create() call.
I am pulling my hair out and would appreciate some assistance. (Assistance fixing the problem, not with pulling hair out.)