Extensions for the .NET Core CLI which help packaging and publishing .NET Core applications
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Go to file
Dirk Kuypers 14f2bd2db4 Add a documemtation section about how to add a systemd service 3 weeks ago
.github/workflows Add GitHub workflow 3 weeks ago
.vscode [vscode] Enable unit tests 5 years ago
Packaging.Targets Bump SharpZipLib to 1.3.3 3 weeks ago
Packaging.Targets.Tests Run tests on .NET 6, 7 and 8 3 weeks ago
boxes Add Fedora 25 box 7 years ago
demo Bump NerdBank.GitVersioning 3 weeks ago
dotnet-deb Drop support for netcoreapp3.1, net5.0 3 weeks ago
dotnet-msi Use McMaster.Extensions.CommandLineUtils 5 years ago
dotnet-rpm Drop support for netcoreapp3.1, net5.0 3 weeks ago
dotnet-tarball Drop support for netcoreapp3.1, net5.0 3 weeks ago
dotnet-zip Drop support for netcoreapp3.1, net5.0 3 weeks ago
molecule Drop support for netcoreapp3.1, net5.0 3 weeks ago
.azure-pipelines-shared.yml Test extracting .tar.gz packages on macOS 5 years ago
.azure-pipelines.yml add support net7 and net8, update linux dependencies 4 weeks ago
.drone.yml add support net7 and net8, update linux dependencies 4 weeks ago
.gitignore Add Molecule test for self-contained app 5 years ago
Directory.Build.props Bump NerdBank.GitVersioning 3 weeks ago
LICENSE Add dotnet-tarball command, AppVeyor script 7 years ago
README.md Add a documemtation section about how to add a systemd service 3 weeks ago
appveyor-testresults.ps1 Fix filename 7 years ago
dotnet-packaging.sln Add dotnet-deb command 7 years ago
version.json Release from master 6 years ago

README.md

Packaging utilities for .NET Core

NuGet Build status

This repository contains command-line extensions for the .NET Core CLI which make it easy to create deployment packages (such as .zip files, tarballs or installers) for .NET Core applications.

The following commands are already available:

  • dotnet tarball - Create a .tar.gz file for Linux and OS X
  • dotnet rpm - Create a CentOS/RedHat Linux installer
  • dotnet zip - Create a .zip file
  • dotnet deb - Create a Ubuntu/Debian Linux installer

And these are up next:

  • dotnet pkg - Create a macOS installer
  • dotnet choco - Create a Chocolatey package
  • dotnet msi - Create a Windows Installer (msi) package

Did we miss anything? Feel free to file a feature request, or send a PR!

Installation

First, install the .NET Packaging tools. You don't need to install all tools if you only plan to use one.

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

Then, in your project directory, run dotnet {zip|tarball|rpm|deb} install to add the tool to your project:

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

Usage

From the command line, run dotnet rpm, dotnet zip or dotnet tarball to create a .rpm, .zip or .tar.gz archive of the published output of your project.

All commands take the following command line arguments:

  • -r, --runtime: The target runtime to build your project for. For example, win7-x64 or ubuntu.16.10-x64.
  • -f, --framework: The target framework to build your project for. For example, netcoreapp1.1 or net462.
  • -c, --configuration: Target configuration. The default for most projects is 'Debug'.
  • -o, --output: The output directory to place built packages in.
  • --version-suffix: Defines the value for the $(VersionSuffix) property in the project.
  • --no-restore: Skip the implicit call to dotnet restore.

All arguments are optional.

Tutorial

Let's create a new console application and package it as a .deb file, so we can install it on our Ubuntu machine:

First, create your console application:

mkdir my-app
cd my-app
dotnet new console

Then, install the dotnet-deb utility:

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

All set. Let's package your application as a deb package:

dotnet deb

There's now a bin\Debug\netcoreapp3.1\my-app.1.0.0.deb file wich you can install:

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

Your application is installed into /usr/share/my-app. Invoke it by running /usr/share/my-app/my-app:

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

Per default a symlink will by created in /usr/local/bin pointing to your application. Therefore it should be in your path and can be invoked just by the application name.

my-app

Creating a Systemd Service

Add a my-app.service file to your project containing at least the following

[Unit]
Description=My awesome app

[Service]
Type=simple
ExecStart=/usr/local/bin/my-app

[Install]
WantedBy=multi-user.target

Add the my-app.service file to an <ItemGroup> of your .csproj with the following content to make sure that it is installed at the right place.

    <Content Include="my-app.service" CopyToPublishDirectory="PreserveNewest" LinuxFileMode="1755">
      <LinuxPath>/etc/systemd/system/my-app.service</LinuxPath>
    </Content>

Make sure to set the Property <InstallService>true</InstallService> in your .csproj file.

Note

You can invoke the packaging tools manually, using a MSBuild target instead of using the a .NET Core CLI tool:

dotnet msbuild [your-project].csproj /t:CreateZip /p:TargetFramework=netcoreapp1.1 /p:RuntimeIdentifier=win7-x64 /p:Configuration=Release