1、首先准备一个演示项目。2、然后将这个项目用FileZilla工具上传到Ubuntu中。3、进入目标文件,接下来有两种方法来部署项目a、用dotnet run命令root@hhz-virtual-machine:~# cd /sourceroot@hhz-virtual-machine:...

1、首先准备一个演示项目。
2、然后将这个项目用FileZilla工具上传到Ubuntu中。
3、进入目标文件,接下来有两种方法来部署项目
a、用dotnet run命令
root@hhz-virtual-machine:~# cd /source root@hhz-virtual-machine:/source# ls Commom ReleaseSample ReleaseSample.sln root@hhz-virtual-machine:/source# cd ReleaseSample root@hhz-virtual-machine:/source/ReleaseSample# ls appsettings.Development.json bin ops.Development.json Program.cs ReleaseSample.csproj appsettings.Production.json obj ops.Production.json Properties ReleaseSample.csproj.user root@hhz-virtual-machine:/source/ReleaseSample# dotnet run -c Release 服务成功开启! 2018/10/8 下午3:37:54 :业务逻辑处理中 2018/10/8 下午3:37:55 :业务逻辑处理中 2018/10/8 下午3:37:56 :业务逻辑处理中 2018/10/8 下午3:37:57 :业务逻辑处理中 2018/10/8 下午3:37:58 :业务逻辑处理中
b、用dotnet publish命令(微软推荐)
root@hhz-virtual-machine:/source/ReleaseSample# dotnet publish -o /data/output -c Release Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Core Copyright (C) Microsoft Corporation. All rights reserved. Restore completed in 40.19 ms for /source/ReleaseSample/ReleaseSample.csproj. Restore completed in 40.19 ms for /source/Commom/Commom.csproj. Commom -> /source/Commom/bin/Release/netstandard2.0/Commom.dll ReleaseSample -> /source/ReleaseSample/bin/Release/netcoreapp2.1/ReleaseSample.dll ReleaseSample -> /data/output/
hhz@hhz-virtual-machine:/data/output$ ls Commom.dll Microsoft.Extensions.FileProviders.Abstractions.dll ReleaseSample.dll Commom.pdb Microsoft.Extensions.FileProviders.Physical.dll ReleaseSample.pdb Microsoft.Extensions.Configuration.Abstractions.dll Microsoft.Extensions.FileSystemGlobbing.dll ReleaseSample.runtimeconfig.json Microsoft.Extensions.Configuration.dll Microsoft.Extensions.Primitives.dll System.Runtime.CompilerServices.Unsafe.dll Microsoft.Extensions.Configuration.FileExtensions.dll Newtonsoft.Json.dll Microsoft.Extensions.Configuration.Json.dll ReleaseSample.deps.json
hhz@hhz-virtual-machine:/data/output$ dotnet ReleaseSample.dll 服务成功开启! 2018/10/8 下午3:43:44 :业务逻辑处理中 2018/10/8 下午3:43:45 :业务逻辑处理中 2018/10/8 下午3:43:46 :业务逻辑处理中 2018/10/8 下午3:43:47 :业务逻辑处理中
4、将部署的项目设置为后台进程
a、用nohup dotnet xxx.dll &命令
root@hhz-virtual-machine:/data/output# nohup dotnet ReleaseSample.dll & [1] 13334 root@hhz-virtual-machine:/data/output# nohup: 忽略输入并把输出追加到'nohup.out' root@hhz-virtual-machine:/data/output# ls Commom.dll Microsoft.Extensions.Configuration.Json.dll Newtonsoft.Json.dll ReleaseSample.runtimeconfig.json Commom.pdb Microsoft.Extensions.FileProviders.Abstractions.dll nohup.out System.Runtime.CompilerServices.Unsafe.dll Microsoft.Extensions.Configuration.Abstractions.dll Microsoft.Extensions.FileProviders.Physical.dll ReleaseSample.deps.json Microsoft.Extensions.Configuration.dll Microsoft.Extensions.FileSystemGlobbing.dll ReleaseSample.dll Microsoft.Extensions.Configuration.FileExtensions.dll Microsoft.Extensions.Primitives.dll ReleaseSample.pdb
由上面的目录我们可以看出,多出了一个nohup.out文件,这个文件是用来放输入信息的:
root@hhz-virtual-machine:/data/output# tail nohup.out 2018/10/8 下午3:52:50 :业务逻辑处理中 2018/10/8 下午3:52:51 :业务逻辑处理中 2018/10/8 下午3:52:52 :业务逻辑处理中 2018/10/8 下午3:52:53 :业务逻辑处理中 2018/10/8 下午3:52:54 :业务逻辑处理中 2018/10/8 下午3:52:55 :业务逻辑处理中 2018/10/8 下午3:52:56 :业务逻辑处理中 2018/10/8 下午3:52:57 :业务逻辑处理中 2018/10/8 下午3:52:58 :业务逻辑处理中 2018/10/8 下午3:52:59 :业务逻辑处理中 root@hhz-virtual-machine:/data/output# tail nohup.out 2018/10/8 下午3:52:52 :业务逻辑处理中 2018/10/8 下午3:52:53 :业务逻辑处理中 2018/10/8 下午3:52:54 :业务逻辑处理中 2018/10/8 下午3:52:55 :业务逻辑处理中 2018/10/8 下午3:52:56 :业务逻辑处理中 2018/10/8 下午3:52:57 :业务逻辑处理中 2018/10/8 下午3:52:58 :业务逻辑处理中 2018/10/8 下午3:52:59 :业务逻辑处理中 2018/10/8 下午3:53:00 :业务逻辑处理中 2018/10/8 下午3:53:01 :业务逻辑处理中
织梦狗教程
本文标题为:.net core系列之《将.net core应用部署到Ubuntu》


基础教程推荐
猜你喜欢
- C#中 Json 序列化去掉null值的方法 2022-11-18
- C#获取指定目录下某种格式文件集并备份到指定文件夹 2023-05-30
- C#中的Linq to JSON操作详解 2023-06-08
- c# – USING块在网站与Windows窗体中的行为不同 2023-09-20
- Unity shader实现高斯模糊效果 2023-01-16
- C#通过标签软件Bartender的ZPL命令打印条码 2023-05-16
- C# 解析XML和反序列化的示例 2023-04-14
- 实例详解C#实现http不同方法的请求 2022-12-26
- Unity 如何获取鼠标停留位置下的物体 2023-04-10
- C#调用摄像头实现拍照功能的示例代码 2023-03-09