将.Net核心控制台应用程序部署到Debian服务器 [英] Deploying .Net core console application to Debian server

查看:184
本文介绍了将.Net核心控制台应用程序部署到Debian服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将简单的.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

已找到要执行的文件(< c $ c>〜/ 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服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆