Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net Core 2.0 with .net framework 4.6.1 - Cannot find reference assembly '.NETFramework/v4.6.1/Microsoft.CSharp.dll

I have recently upgraded my project from asp.net core 1.1 to asp.net core 2.0. and app us using .Net framework 4.6.1. Application is working as expected on local dev machine but once it deployed to server with dotnet publish command I am seeing this error

InvalidOperationException: Cannot find reference assembly '.NETFramework/v4.6.1/Microsoft.CSharp.dll' file for package Microsoft.CSharp.Reference

I have also noticed that ref folder that use be present when using asp.net core 1.1 when published is now missing. How to fix this issue.

like image 957
Praneeth Avatar asked Feb 07 '18 19:02

Praneeth


2 Answers

Same issue was resolved when MvcRazorCompileOnPublish was added to .csproj file.

Give it a try.

<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
like image 115
Steve Tolba Avatar answered Oct 22 '22 13:10

Steve Tolba


I noticed if you have the Views folder included with the compiled View.dll when you start your IIS pool, you get this error. I was doing this on purpose for a short term work around hack.

like image 41
Donny V. Avatar answered Oct 22 '22 14:10

Donny V.