我应该安装哪个包来运行已部署的.Net Core 应用程序?

我应该安装哪个包来运行已部署的.Net Core 应用程序?

我正在构建一个 .Net Core API,它将托管在基于 Ubuntu 的服务器上。我正在服务器上安装所需的软件包,即 MySQL 和 Nginx,但当然,我还需要安装 .Net Core 才能运行应用程序。

我发现了一个教程示例如何设置和配置 Nginx 以与 Kestrel 服务器协同工作,但它完全假设您已经在将要部署的机器上安装了 .Net Core。

.Net Core 网站似乎仅指导您安装 SDK,但这用于部署,而不是开发,因此安装 .Net Core 运行时是有意义的,但是当执行apt-cache search dotnet查找特定包名称时,我发现dotnet-hosting-2.0.0列出了“Microsoft .NET Core 2.0.0 Linux Server Hosting”描述。

总而言之,我的问题很简单。要托管 .Net Core 应用程序,您是否使用dotnet-hostingdotnet-runtime部署 .Net Core 应用程序的包?

答案1

经过进一步的研究,我发现该dotnet-hosting软件包结合了dotnet-runtimeaspnetcore-store软件包。已验证这个 Github 评论

运行时和运行时存储被打包到“Linux 服务器托管”安装程序中,包名为dotnet-hosting-2.0.0


aspnetcore-store现在是默认必需依赖项在已发布的 ASP.Net Core 应用程序上。

默认情况下,ASP.NET 应用程序发布时依赖于运行时存储。


因此,直接回答我的问题,dotnet-hosting-x.x.x在部署 ASP.Net Core 应用程序时应该安装。这还将消除aspnetcore-store未随dotnet-runtime包一起安装时出现的以下错误。

Error: An assembly specified in the application dependencies manifest (APIproject.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


我已经在 Ubuntu 16.04 上使用我的应用程序亲自测试了该软件包,并且运行良好。

相关内容