【发布时间】:2019-02-16 06:52:36
【问题描述】:
我正在尝试按照this tutorial 中的说明在 Ubuntu Server 16.04 LTS 上托管 ASP.Net Core MVC 应用程序。
在 Linux 机器上,我使用 git pull 拉入我的项目。我使用dotnet build 成功构建了它,它触发了包还原。我使用dotnet publish -c Release -r linux-x64 成功发布它。我将目录更改为bin/Release/netcoreapp2.1 并运行sudo cp ./*.* /var/aspnetcore/myapp/ 将文件复制到我托管项目的目录中。我导航到该目录并输入dotnet myapp.dll - 应用程序开始侦听端口 5000 和 5001,然后从另一台计算机上,我可以在浏览器中输入我的域名并查看网站,这意味着 Nginx 反向代理和 Kestrel一定可以正常工作。
现在我想将应用程序作为服务运行,以便它在计算机上启动、在崩溃时重新启动、记录错误等,但是当我输入 sudo systemctl start kestrel-myapp.service 时它会立即崩溃并尝试每 10 秒重新启动一次但失败。日志显示错误:An assembly in the application dependencies manifest (myapp.deps.json) was not found: package: 'Microsoft.EntityFrameworkCore.Relational.Design', version '1.1.5' path: 'lib/netstandard1.3/Microsoft.EntityFrameworkCore.Relational.Design.dll' Main process exited, code=exited, status=140/n/a
所以,1.1.5 版本看起来有点低,但我更新了所有的 NuGet 包,它仍然想使用它。另外,如果依赖项有问题,我不明白为什么dotnet myapp.dll 不会崩溃。有人知道如何解决这个问题吗?
这是我的服务文件:
[Unit]
Description=myapp ASP.Net Core MVC Application
[Service]
WorkingDirectory=/var/aspnetcore/myapp
ExecStart=/usr/bin/dotnet /var/aspnetcore/myapp/myapp.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
SyslogIdentifier=myapp
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
额外问题:我应该将我的 wwwroot 文件夹与我的静态文件复制到哪里?应用程序运行但找不到我的任何 javascript 或 css 文件,我不确定它们属于哪里。
【问题讨论】:
-
顺便说一下,文件夹/lib/netstandard1.3不存在。
标签: linux ubuntu asp.net-core .net-core