當前位置: 妍妍網 > 碼農

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

2024-04-21碼農

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

    然後,在您的計畫目錄中,執行 dotnet z tarball i rpm p deb install 將該工具添加到您的計畫中:

    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

    分享

    點收藏

    點點贊

    點在看