编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

太方便了,开源的 .NET Core 打包工具

wxchong 2024-06-27 01:30:32 开源技术 16 ℃ 0 评论

dotnet-packaging



推荐一个开源的 .NET Core 打包工具,100 % 使用 C# 开发,它包含了 .NET Core CLI 的命令行扩展,所以可以轻松为 .NET Core 应用程序创建部署包,比如 windows msi 文件、 Linux 安装程序 deb、 macOS 安装程序 pkg 等等,非常方便。


常用命令



  • dotnet pkg - 创建 macOS 安装程序
  • dotnet deb - 创建 Ubuntu/Debian Linux 安装程序
  • dotnet zip - 创建 .zip 文件
  • dotnet msi - 创建 Windows Installer (msi) 包



如何安装



首先,安装全局 .NET 打包工具。如果您只打算使用一个工具,则无需安装所有工具。

dotnet tool install --global dotnet-zip
dotnet tool install --global dotnet-tarball
dotnet tool install --global dotnet-rpm
dotnet tool install --global dotnet-deb

然后,在您的项目目录中,运行 dotnetztarballirpmpdebinstall 将该工具添加到您的项目中:

dotnet zip install
dotnet tarball install
dotnet rpm install
dotnet deb install



使用教程



让我们创建一个新的控制台应用程序并将其打包为 .deb 文件,以便我们可以将其安装在 Ubuntu 计算机上:

首先,创建您的控制台应用程序:

mkdir my-app
cd my-app
dotnet new console

然后,安装 dotnet-deb 实用程序:

dotnet tool install --global dotnet-deb
dotnet deb install

可以了,让我们将您的应用程序打包为 deb 包:

dotnet deb

现在有一个可以安装的 bin\Debug\netcoreapp3.1\my-app.1.0.0.deb 文件:

apt-get install bin\Debug\netcoreapp3.1\my-app.1.0.0.deb

您的应用程序已安装到 /usr/local/share/my-app 中。通过运行 /usr/local/share/my-app/my-app 来调用它:

/usr/local/share/my-app/my-app


如您所见,dotnet-packaging 使用非常简单,您可以使用它轻松的创建各个平台的安装包,只需要一行命令即可。

项目地址



https://github.com/quamotion/dotnet-packaging


分享
点收藏

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表