Home >Backend Development >C#.Net Tutorial >.NET Core CLI tool documentation dotnet-publish
Name
dotnet-publish - Package the application and all its dependencies into a folder, get ready to publish
Summary
`dotnet publish [--framework]
[--runtime] [--build-base-path] [--output] [--version-suffix] [--configuration] [<project>]`
Description
dotnet publish Compile the application, By reading the dependencies specified in the project.json file and publishing the result set files to a directory.
Depending on the type of portable app, the resulting directory will contain the following:
Portable Application - The application's intermediate language (IL) code and all the application's associated dependencies.
Local Dependencies for Portable Apps - Supported platforms with each local dependency in the above subdirectory.
Self-Contained Application - Same as above, with the entire runtime for the target platform attached.
Option
[project]
dotnet publish requires access to the project.json file to work. If it is not called with a specified [project], project.json in the current directory will be the default.
If no project.json can be found, dotnet publish will throw an error.
-f, --framework [FID]
Publish an application with the given framework identification (FID). If not specified, FID is read from project.json. The command will throw an error when no valid frame is found. If multiple valid frames are found, the command will issue all valid frames.
-r, --runtime [RID]
Release the given runtime application.
-b, --build-base-path [DIR]
Directory for temporary output.
-o, --output
Specify the path where to place the directory. If not specified, it will default to ./bin/[configuration]/[framework]/ for portable applications or ./bin/[configuration]/[framework]/[runtime] for self-contained applications.
--version-suffix [VERSION_SUFFIX]
Defines what * is replaced in the version field in the project.json file.
-c, --configuration [Debug|Release]
Configuration when releasing. The default value is Debug.
Example
dotnet publish
Publish an application using the framework found in project.json. If project.json contains a runtimes node, the published RID is the current platform.
dotnet publish ~/projects/app1/project.json
Publish the application using the specified project.json.
dotnet publish --framework netcoreapp1.0
Use the netcoreapp1.0 framework to publish the current application.
dotnet publish --framework netcoreapp1.0 --runtime osx.10.11-x64
Publish the current application using the netcoreapp1.0 framework and the OS X 10.10 runtime. This RID must exist in the runtimes node in project.json.
【Related recommendations】
1. Graphic verification code for .Net Core
2. .NET Core configuration file loading and DI injection of configuration data
3. Detailed introduction to ZKEACMS for .Net Core
4. Share the example code of using forms verification in .net MVC