.NET Core 发布(dotnet publish)


一、需求

使用.net core 3.0建的项目,一般情况下,每次想发布都要打开vs,然后点击发布,选择配置;
如果想用cmd命令行发布,应该怎么写呢?

二、方法

项目目录如下:
在这里插入图片描述

1、打开cmd窗口,cd到当前目录,执行如下语句:

dotnet publish -c Release -r win-x64 -o ./publish/psma --self-contained true

在这里插入图片描述
项目发布成功:
在这里插入图片描述
效果如同使用vs发布:
在这里插入图片描述

2、创建一个用于发布的bat批处理文件

bat文件中写入如下命令:

cd /d %~dp0
dotnet publish -c Release -r linux-x64 -o ./publish/psma --self-contained true
pause

以管理员身份运行:
在这里插入图片描述

三、参考

https://docs.microsoft.com/zh-cn/dotnet/core/tools/dotnet-publish?tabs=netcore21


猜你喜欢

转载自www.cnblogs.com/willingtolove/p/11960434.html