dotnet publish
The dotnet command that compiles an app and gathers everything needed to run it into a folder or container image, ready to deploy.
In more detail
Options decide who supplies the runtime (framework-dependent or self-contained), whether code is trimmed, and whether the result is a container. Use -c Release for production builds.
Example
dotnet publish -c ReleaseRelated terms
- Release configuration — The build configuration that compiles with optimisations for production, as opposed to the Debug configuration used while developing.
- self-contained deployment — Publishing an app together with its own copy of the .NET runtime, so the host needs no .NET installed.
- trimming — A publishing option that removes code the trimmer can prove is unused, making a self-contained app or image smaller.
- container publishing — Using dotnet publish to build a container image of an app directly, without writing a Dockerfile.
Taught in
- Solutions, Projects, and Target Frameworks — Modern .NET Core, C# & Enterprise Microservices
- OpenTelemetry, Container Publishing and Trimming — Modern .NET Core, C# & Enterprise Microservices