[英]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.我最近将我的项目从 asp.net core 1.1 升级到 asp.net core 2.0。 and app us using .Net framework 4.6.1.并使用 .Net 框架 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应用程序在本地开发机器上按预期工作,但是一旦它使用 dotnet publish 命令部署到服务器,我就会看到这个错误
InvalidOperationException: Cannot find reference assembly '.NETFramework/v4.6.1/Microsoft.CSharp.dll' file for package Microsoft.CSharp.Reference InvalidOperationException:找不到包 Microsoft.CSharp.Reference 的参考程序集“.NETFramework/v4.6.1/Microsoft.CSharp.dll”文件
I have also noticed that ref folder that use be present when using asp.net core 1.1 when published is now missing.我还注意到在发布时使用 asp.net core 1.1 时使用的ref文件夹现在丢失了。 How to fix this issue.如何解决这个问题。
Same issue was resolved when MvcRazorCompileOnPublish was added to .csproj file.当 MvcRazorCompileOnPublish 添加到 .csproj 文件时,同样的问题得到解决。
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.我注意到如果在启动 IIS 池时编译的 View.dll 中包含 Views 文件夹,则会出现此错误。 I was doing this on purpose for a short term work around hack.我这样做是为了在 hack 周围进行短期工作。
在我的情况下(我在控制台应用程序模式下运行 .Net core)上述解决方案都不起作用,我只是从 这个链接下载了 .Net Framework 4.6.1。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.