dotnet publish --output bin/publish adds the name of the project to the publish path
See original GitHub issueLeaving the --output parameter to its default value means that the project will be published to bin/Release/netcoreap2.0/publish By that I mean that the dlls etc can be found in the folder named publish in that path.
If you use the --output parameter to change the publish path, the behavior changes unexpectedly.
doing dotnet publish --output bin/publish
means the project will be published to bin/publish/ProjectName instead of just the publish folder named.
This is obviously bad and confusing, and should be changed. In the mean time, is there a way to workaround this problem?
Steps to reproduce
Create an empty netcoreapp2.0 web project. publish it to a specific folder using dotnet publish --output bin/publish
Expected behavior
The app dll is published to bin/publish
Actual behavior
The app dll is published to bin/publish/ProjectName
Environment data
dotnet --info
output:
.NET Core SDK (reflecting any global.json):
Version: 2.1.401
Commit: 91b1c13032
Runtime Environment: OS Name: Windows OS Version: 10.0.16299 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.401\
Host (useful for support): Version: 2.1.3 Commit: 124038c13e
.NET Core SDKs installed: 2.1.401 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.3-servicing-26724-03 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top GitHub Comments
found it:
modifyOutputPath Add project name to publish path | (Optional) If true, folders created by the publish command will have project file name prefixed to their folder names when output path is specified explicitly in arguments. This is useful if you want to publish multiple projects to the same folder. Default value: true
It should be set as false
I’ve got the same issue on Azure Pipelines using the following task for an ASP.NET Core 2.2 application.
The publish logs will output the following:
ExampleNetCoreApp -> /home/vsts/work/1/s/ExampleNetCoreProject/ExampleNetCoreApp/drop-packages-dotnetcore/ExampleNetCoreApp/
For some reason it adds another directory to the publish path with the same name as the project. The publish command doesn’t have this behavior when testing it on my local machine. The task is running on a ubuntu-16.04 image.
EDIT:
Not sure if this is expected behavior or not since it publishes a zipped directory, but I’ve disabled zipping it so it just publishes a regular directory inside the output map. Either way the behavior of the CLI command on Azure is different than locally publishing it…
Found out about this when trying to run the application in a Docker container but it couldn’t find the .dll in the published map (because it added the extra directory, where the .dll actually located!).
The documentation isn’t really clear about it either…