将.Net核心控制台应用程序部署到Debian服务器

编程入门 行业动态 更新时间:2024-10-18 14:23:34
本文介绍了将.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

已找到要执行的文件(〜/ 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服务器

本文发布于:2023-11-08 07:30:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568731.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制台   应用程序   核心   服务器   Net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!