今天把原来 .Net 4.6 的程序转成了 .Net Core 的,正常发布到服务器上,但是运行的时候,出现了如下的错误
Error:
An assembly specified in the application dependencies manifest (WXService.deps.json) was not found:
package: 'Microsoft.AspNetCore.Antiforgery', version: '2.0.2'
path: 'lib/netstandard2.0/Microsoft.AspNetCore.Antiforgery.dll'
This assembly was expected to be in the local runtime store as the application was published using the following target manifest files:
aspnetcore-store-2.0.6.xml
目测是服务器上没有对应的依赖,估计是发布的时候没有完整发布。
解决方法就是在项目文件 csproj 中添加如下的开关<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>