缺少DLL将.Net核心部署到ubuntu中

时间:2017-12-16 12:28:19

标签: ubuntu asp.net-core

您好我很难将我的示例.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会出现在下面的路径中。我添加了屏幕截图 enter image description here 同样的事情当我做sudo dotnet发布-c发布-o / var / webapps / Core只在我能看到的文件下面。我在下面添加了屏幕截图。

enter image description here 观察到这一点后,我觉得这是我缺少所有必需的DLL的地方。我只是假设这是因为我的错误消息显示缺少包:' Microsoft.AspNetCore.Antiforgery',版本:' 2.0.1'。我也在https://github.com/NiranjanAbb/Core.git在GIT中找到了我的解决方案。有人可以帮我解决这个问题吗?因为有一个星期我正在努力学习将.net部署到ubuntu中。任何帮助将不胜感激。感谢

enter image description here

2 个答案:

答案 0 :(得分:1)

我相信你错过了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/

答案 1 :(得分:0)

您可能想签出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 restoredotnet deb -c Release -r ubuntu.18.04-x64 -f netcoreapp2.0。这将创建一个.deb文件,可用于将应用程序部署到Ubuntu。

让我知道怎么回事!

相关问题