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.
Same issue was resolved when MvcRazorCompileOnPublish was added to .csproj file.
Give it a try.
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With