title: .NET Core project running .NET Framework "Cannot find reference assembly Microsoft.CSharp.dll"
body: <p>I have recently added MVC in my .NET Core 2.0 project which runs on .NET Framework 4.7 (<code>&lt;TargetFramework&gt;net47&lt;/TargetFramework&gt;</code>). It is a Web-project which gets hosted locally via a Kestrel-server. Before I added MVC there were no issues.</p>
  
  <p>I build it on my developer machine (Visual Studio 2017) and when I run it there, it works correctly. (because there exists the folder: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7 with all the required assemblies). These are added in the project as assemblies (automatically).</p>
  
  <p>But when I copy the bin/release to a new Win10 machine (where .NET Framework 4.7 is installed) and try to run it there, it fails with following exception:</p>
  
  <blockquote>
    <p>System.InvalidOperationException: Cannot find reference assembly
    '.NETFramework/v4.7/Microsoft.CSharp.dll' file for package
    Microsoft.CSharp.Reference</p>
  </blockquote>
  
  <p>If I copy this dll manually into the bin, the exception continues to appear because of the next dll. I copied: Microsoft.CSharp, mscorlib, System, System.ComponentModel.Composition, System.ComponentModel.DataAnnotations, System.Core, System.Data, System.Drawing, System.IO.Compression.FileSystem, ... So you see it doesn't end.</p>
  
  <p>I also tried these suggestions:</p>
  
  <ul>
  <li>adding <code>&lt;PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.0.0" /&gt;</code> to .csproj (<a href="https://github.com/dotnet/sdk/issues/1488" rel="nofollow noreferrer">https://github.com/dotnet/sdk/issues/1488</a>)</li>
  <li>adding <code>&lt;DependsOnNETStandard&gt;netstandard2.0&lt;/DependsOnNETStandard&gt;</code> to .csproj</li>
  <li>adding <code>&lt;MvcRazorCompileOnPublish&gt;true&lt;/MvcRazorCompileOnPublish&gt;
  &lt;MvcRazorExcludeRefAssembliesFromPublish&gt;false&lt;/MvcRazorExcludeRefAssembliesFromPublish&gt;</code> to .csproj (<a href="https://stackoverflow.com/questions/48671906/asp-net-core-2-0-with-net-framework-4-6-1-cannot-find-reference-assembly-ne">Asp.net Core 2.0 with .net framework 4.6.1 - Cannot find reference assembly &#39;.NETFramework/v4.6.1/Microsoft.CSharp.dll</a>)</li>
  <li>creating a new .NET core 2.0 project with .NET Framework 4.7 and adding MVC. I tested if it would work on the other machine and it did. There were no missing assemblies. -> then I compared this solution to my solution, compared the NuGet packages and Startup.cs, but I could not find anything that was different.</li>
  </ul>
  
  <p>There just has to be something wrong in my project but I'm really clueless now what that could be and I would be extremely thankful if someone could give me some advice.</p>