Linux command
dotnet-publish 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Publish for deployment
dotnet publish
Publish Release build
dotnet publish -c Release
Publish self-contained
dotnet publish -r [linux-x64] --self-contained
Publish single file
dotnet publish -r [linux-x64] -p:PublishSingleFile=true
Publish to directory
dotnet publish -o [./publish]
Publish trimmed
dotnet publish -r [linux-x64] -p:PublishTrimmed=true
说明
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.
参数
- -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.
FAQ
What is the dotnet-publish command used for?
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.
How do I run a basic dotnet-publish example?
Run `dotnet publish` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -c, --configuration _CONFIG_ do in dotnet-publish?
Build configuration.