Specifies the path for the output directory.
If not specified, it defaults to [project_file_folder]./bin/[configuration]/[framework]/publish/ for a runtime-dependent
executable and cross-platform binaries.
It defaults to [project_file_folder]/bin/[configuration]/[framework]/[runtime]/publish/ for a self-contained executable.
In a web project, if the output folder is in the project folder, successive dotnet publish
commands result in nested
output folders. For example, if the project folder is myproject, and the publish output folder is
myproject/publish, and you run dotnet publish
twice, the second run puts content files such as
.config and .json files in myproject/publish/publish. To avoid nesting publish folders, specify a
publish folder that is not directly under the project folder, or exclude the publish folder from the project.
Some behaviour depends on the SDK version:
-
.NET Core 3.x SDK and later: If a relative path is specified when publishing a project, the output directory generated is
relative to the current working directory, not to the project file location.
If a relative path is specified when publishing a solution, all output for all projects goes into the specified folder
relative to the current working directory. To make publish output go to separate folders for each project, specify a relative
path by using the msbuild PublishDir
property instead of this option.
-
.NET Core 2.x SDK: If a relative path is specified when publishing a project, the output directory generated is relative to
the project file location, not to the current working directory.
If a relative path is specified when publishing a solution, each project's output goes into a separate folder relative to the
project file location. If an absolute path is specified when publishing a solution, all publish output for all projects goes
into the specified folder.