嗨,我发现很难将我的示例.net核心应用程序部署到ubuntu中。最初我跟随http://blog.bobbyallen.me/2017/05/01/deploying-and-hosting-asp-net-core-applications-on-ubuntu-linux/这个博客,并成功地能够在ubuntu上部署这个示例应用程序。此特定应用程序位于.net core 1.0中。我在VS2017中使用.Net core 2.0创建了示例应用程序。我成功地将.net和nginx安装到ubuntu中。每当我点击sudo -u www-data dotnet /var/webapps/Core/Core.dll
我都会得到以下错误
Error:
An assembly specified in the application dependencies manifest (Core.deps.json) was not found:
package: 'Microsoft.AspNetCore.Antiforgery', version: '2.0.1'
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.3.xml
我在Sample解决方案(lk2)中观察到,每当我们使用命令sudo dotnet publish -c Release -o /var/webapps/lk2
发布应用程序时,我看到很多dll将出现在下面的路径中。我添加了屏幕截图当我做sudo dotnet发布同样的事情-c发布-o / var / webapps / Core只有我能看到的文件下面。我在下面添加了屏幕截图。
观察到这一点后,我觉得这是我缺少所有必需的DLL的地方。我只是假设这是因为我的错误消息显示缺少包:'Microsoft.AspNetCore.Antiforgery',版本:'2.0.1'。我也在https://github.com/NiranjanAbb/Core.git的GIT解决方案。有人可以帮我解决这个问题吗?因为有一个星期我正在努力学习将.net部署到ubuntu中。任何帮助将不胜感激。谢谢
我相信你错过了dotnet-hosting
套餐......
在安装主机软件包之前,您需要安装“dotnet产品Feed”。你可以在这里找到它 - https://www.microsoft.com/net/core#linuxubuntu或者我们新的Ubuntu 16.04服务器你可以运行它:
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
确保更新apt-get或者您无法安装任何.NET核心软件包,然后安装托管软件包:
更新系统上的软件包:
sudo apt-get update
安装Linux Server Hosting运行时和存储:
sudo apt-get install dotnet-hosting-2.0.0
如果您有兴趣,我写了一篇关于在Linux上托管ASP.NET Core的博客,可以在这里找到 - https://www.tonyranieri.com/blog/2017/10/27/Hosting-.Net-Core-On-Linux/
您可以查看dotnet-packaging。它包括一个dotnet deb
命令行实用程序,它允许您创建一个.deb
文件(即Ubuntu安装程序),您可以使用它来在Ubuntu上安装您的应用程序。它应该使您更容易部署。
首先,您需要将此部分添加到.csproj
文件中:
<ItemGroup>
<PackageReference Include="Packaging.Targets" Version="0.1.45" />
<DotNetCliToolReference Include="dotnet-deb" Version="0.1.45" />
<ItemGroup>
然后,运行dotnet restore
和dotnet deb -c Release -r ubuntu.18.04-x64 -f netcoreapp2.0
。这将创建一个.deb
文件,您可以使用该文件将您的应用程序部署到Ubuntu。
让我知道这是怎么回事!