use*_*804 6 startup .net-core asp.net-core .net-core-2.0 .net-core-2.1
我将我的 ASP.NET CORE 应用程序从 sdk .NET Core 2.0 升级到 .NET Core 2.1。我可以在我的本地主机中运行该解决方案,但是当我将它部署到另一台服务器时出现异常。例外如下。到目前为止,我为解决该问题所做的步骤如下,并且我所做的所有修改都引发了相同的错误,似乎没有任何效果。有没有人有任何建议如何解决这个问题?
我做过的步骤:
修改项目的设置
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
<RuntimeFrameworkVersion>2.1.0</RuntimeFrameworkVersion>
<UseNETCoreGenerator>true</UseNETCoreGenerator>
<RazorCompileOnBuild>true</RazorCompileOnBuild>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)我还在 web.config 中添加了绑定重定向
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"
bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.1.0"
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.1.0" />
</dependentAssembly>
</assemblyBinding>
Run Code Online (Sandbox Code Playgroud)在服务器上安装 .net core 2.1
例外 :
Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException:发生一个或多个编译失败:错误 CS1705:程序集版本=1.0.0.0,Culture=neutral,PublicKeyToken=null'使用'System.Runtime,Version=4.2.1.0,Culture =neutral, PublicKeyToken=b03f5f7f11d50a3a' 其版本高于引用的程序集 'System.Runtime',标识为 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
我有同样的问题。当我将Views解决方案中的文件夹添加到该publish文件夹时,问题就消失了。由于某种原因,Razor 要求这些源文件存在于服务器中并且是最新的,即使它也将它们编译为 .dll。因此,奇怪的是,在发布过程中 Views 文件夹不会自动复制。
我个人做了这样的连接
junction "MyProject\bin\Release\netcoreapp2.1\linux-x64\publish\Views" "MyProject\Views"
或者,禁用以下行可能会有所帮助(尚未测试,但此问题似乎相关,因为在 Net.Core 的早期版本中没有 Razor 编译)。
<RazorCompileOnBuild>true</RazorCompileOnBuild>
到
<RazorCompileOnBuild>false</RazorCompileOnBuild>
| 归档时间: |
|
| 查看次数: |
5148 次 |
| 最近记录: |