我在将简单的.Net核心控制台应用程序部署到linux服务器时遇到一些问题。
I have some problem with deploy simple .Net core console application to linux server.
我已经通过这种方式创建了简单的控制台Hello world应用程序:
I've created simple console Hello world application this way:
dotnet new console -o hello然后我在devlop计算机上测试了该应用程序
Then I tested this application on my devlop computer
dotnet run工作正常。
接下来,我以这种方式创建了到debian平台的发行版
Next I created release to debian platform this way
dotnet publish -c release -r debian.8-x64 --self-contained现在我有一个包含分发文件夹了
Now I have a folder with distribution
C:\Projects\C#\hello\bin\MCD\release\netcoreapp2.0\debian.8-x64我还带了文件夹debian.8-x64并使用Debias 8 OS复制到我的Linux计算机上。
Further I took folder debian.8-x64 and copied to my linux computer with Debias 8 OS
已找到要执行的文件(〜/ debian.8-x64 / hello )并将其更改为模式
Found file for execution (~/debian.8-x64/hello) and changed it mode
chmod +x ./hello现在我正在尝试执行文件
Now I'm trying to execute file
./hello并有例外情况
root@my2ndbox:/home/alex/temp/debian.8-x64# ./hello Error: An assembly specified in the application dependencies manifest (hello.deps.json) was not found: package: 'runtime.linux-x64.Microsoft.NETCore.App', version: '2.0.0' path: 'runtimes/linux-x64/lib/netcoreapp2.0/Microsoft.CSharp.dll'在Linux机器上安装了Net Framework,其版本与在我的开发计算机上
Net framework is installed on Linux machime with the same version as on my develop computer
root@my2ndbox:/home/alex/temp/debian.8-x64# dotnet --version 2.0.2什么可能导致这种类型的错误?
What may cause this type of error?
推荐答案您正在复制错误的内容以进行部署。 dotnet发布时,应使用 publish 目录的内容。对于您的情况,应为 release / netcoreapp2.0 / debian.8-x64 / publish / 。
You are copying the wrong stuff for deployment. When you dotnet publish, you should use the contents of the publish dir. For your case, it should be release/netcoreapp2.0/debian.8-x64/publish/.
如果您使用非发布目录( release / netcoreapp2.0 / debian.8-x64 / ),它将假定您要在开发模式下运行项目,并且希望使用本地nuget缓存中的资产,这很可能会在您的部署计算机上丢失。
If you use the non-publish directory (release/netcoreapp2.0/debian.8-x64/), it will assume you want to run your project in development mode, and expects to use assets from the local nuget cache, which will most likely be missing on your deployment machine.
FWIW,您做的一些事情很奇怪。首先,您需要确定是否要真正使用独立的部署。如果是这样,您甚至不需要在要进行部署的计算机上安装dotnet。
FWIW, you are doing a few things very strangely. First, you need to decide if you want to really use self-contained deployments or not. If you are, you dont even need dotnet installed on the machine you are trying to deploy on.
更多推荐
将.Net核心控制台应用程序部署到Debian服务器
发布评论