.net core项目部署Linux服务器时出现SDK版本问题解决方案(2步解决)
问题描述:
[root@localhost GDSM4.1.002]# dotnet GDSMPlateForm.dll
Error:
An assembly specified in the application dependencies manifest (GDSMPlateForm.deps.json) was not found:
package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.1.1'
path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.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.0-linux-x64.xml;aspnetcore-store-2.0.0-osx-x64.xml;aspnetcore-store-2.0.0-win7-x64.xml;aspnetcore-store-2.0.0-win7-x86.xml
查找原因(网上找资料):
Windows就没有这么麻烦了,安装Windows Server Hosting就可以了,微软已经为你打包好了.Net Core Runtime和ASP.Net Core Runtime
解决办法(2步):
1、发布时指定SDK版本
在项目的根目录打开cmd,执行命令即可:
dotnet new global.json --sdk-version <SDK版本号>
注意:最后的参数是SDK版本,不是.NET Core 版本
2、修改发布配置文件
在<PropertyGroup>节点增加 <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
缺点和不足:这样发不完可以在Linux指定版本上正常运行,但是缺点是发布包的包体大小有差别,所以最好还是升级服务器环境版本(和开发环境一致)
其实文件个数就能看出来,其实是后者包里包含很多之前依赖的包
总结:喜欢这个找问题的过程,记录一下
本文来自博客园,作者:汪小让,转载请注明原文链接:https://www.cnblogs.com/wangxiaorang/p/15117735.html