LinuxCommandLibrary

dotnet-publish

deployment package builder and publisher

TLDR

Publish for deployment

$ dotnet publish
copy
Publish Release build
$ dotnet publish -c Release
copy
Publish self-contained app
$ dotnet publish -r [linux-x64] --self-contained
copy
Publish single file
$ dotnet publish -r [linux-x64] -p:PublishSingleFile=true
copy
Publish to directory
$ dotnet publish -o [./publish]
copy
Publish trimmed (smaller output)
$ dotnet publish -r [linux-x64] -p:PublishTrimmed=true
copy

SYNOPSIS

dotnet publish [project] [options]

DESCRIPTION

dotnet publish compiles and packages an application for deployment. It produces a directory containing the application, dependencies, and optionally the .NET runtime itself.
Self-contained deployment includes the runtime, eliminating target machine .NET requirements. Framework-dependent deployment assumes .NET is installed, producing smaller output.
Advanced options like single-file publishing and trimming optimize output for specific deployment scenarios.

PARAMETERS

PROJECT

Project or solution to publish.
-c, --configuration CONFIG
Build configuration.
-r, --runtime RID
Target runtime identifier.
--self-contained [BOOL]
Include .NET runtime.
-o, --output DIR
Output directory.
-p:PROP=VALUE
Set MSBuild property.
--no-build
Skip build, use existing output.
--help
Display help information.

CAVEATS

Self-contained apps are larger. Trimming may remove needed code. Runtime identifiers must match target system. Cross-platform publishing may need additional SDKs.

HISTORY

dotnet publish is part of the .NET CLI, providing standardized deployment artifact creation across platforms. It replaced platform-specific deployment methods in legacy .NET.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community