How do I configure VS 2015 to enable Roslyn's C# scripting capabilities?
I've tried installing various Nuget packages, including both the 1.0 and 1.1.0-beta1 versions of Microsoft.CodeAnalysis.CSharp, Microsoft.CodeAnalysis.Scripting.CSharp, etc., but I can't get any of the examples I've found online to work. I am getting "type not found" errors, i.e.,
var scriptEngine = new ScriptEngine();
... fails because the type "ScriptEngine" is not found.
Can someone provide as recipe that includes which nuget packages to install, which using statements are required, etc., to implement Roslyn scripting?
UPDATE #1:
I have made some progress, but still having issues. I get a bunch of compiler warnings and then a TypeInitilizationException which is apparently due to a component version mismatch.
I'm now using the following example code (taken from a test), and there's no missing types:
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've loaded all of the nightly packages that are available at https://www.myget.org/F/roslyn-nightly/.
I get a series of build warnings that refer to Microsoft.CodeAnalysis, v1.1.0.0.
Running the exe despite the warnings yields the TypeInitilizationException mentioned above. Based on the stacktrace, the TypeInitializationError is caused by a version mismatch for System.Reflection.Metadata.dll.
I am not sure where to go from here. I don't understand how the scripting-related packages/components fit together. I saw some posts from earlier this year that describe building Roslyn completely. I have not done that. Is that necessary?
This is reminding me of DLL hell from the old days.