[2018.4] Using Roslyn Code Analyser

Long story short, I’d like to use the Roslyn Code Analyser to compile C# code at runtime. I’m wondering if that’s possible with the advent of C# 7 being included in Unity. I’ve tried to NuGet the Roslyn stuff into my Visual Studio project and copy the .dlls into my Assets folder, but Unity complains about dependencies. Visual Studio does not.

So I solve those dependencies. And more dependencies pop up, and I solve those, and so on and so on until I get bored. Must have gone on for an hour or more. Got to ludicrous stuff like SQLitePCLRaw stuff. I think it was just trying to include literally everything available in the C# language.

I’d rather not use the Asset Store solutions, as I’d like to learn how to do it myself.

So I’m going to answer my own question.

You’ve just gotta keep on including those ridiculous dependencies until the compiler gets tired and goes to sleep. Then it works! I’ve got Roslyn scripting in my game working perfectly.