title: How Can I Use Roslyn in an ASP.NET MVC 5 App?
body: <p>I have an ASP.NET MVC 5 app (5.2.7 to be exact) targetting .NET Framework 4.7.2. I'm trying to add a feature for validation rules on objects. I have a bunch of conditions that I transform into a C# script which I want to evaluate using <code>CSharpScript.EvaluateAsync</code>.</p>
  
  <p>I have a prototype of this working in LINQPad and was trying to port it into the main project. Because the main project was being developed on C# 5 in VS2013, I decided it was time to upgrade to C# 7.3 and VS2017, so I did. After cleaning up everything after the upgrade, I decided to implement the prototype.</p>
  
  <p>I first added the <code>Microsoft.CodeAnalysis.Scripting</code> NuGet package to the main project, but when I tried to run the application, I got all kinds of exceptions from what I presume was library conflicts between MVC 5 and whatever the package dependencies were.</p>
  
  <p>I then reverted and tried making a separate project in which to have the validation rules code. When I ran the application, it loaded and everything seemed fine, until I tried to trigger a validation rule. At that point it threw an exception:</p>
  
  <blockquote>
    <p>Could not load file or assembly 'Microsoft.CodeAnalysis.Scripting, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.</p>
  </blockquote>
  
  <p>In a round about way I'm back to the problem of the main project trying to load the NuGet package.</p>
  
  <p>So,... Is there a way I can make the two work together or no? If no, what are my next choices to make it work? Migrate to ASP.NET Core? I intend to do that in the future, just trying to avoid it right now because the solution is rather large, after 4 years of working on it...</p>