question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet publish --output bin/publish adds the name of the project to the publish path

See original GitHub issue

Leaving 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
katlimruizcommented, Jun 18, 2019

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

0reactions
justinmoorcommented, Feb 28, 2019

I’ve got the same issue on Azure Pipelines using the following task for an ASP.NET Core 2.2 application.

  displayName: 'Publish sample .NET Core App'
  inputs:
    command: publish
    publishWebProjects: false
    zipAfterPublish: false
    projects: 'ExampleNetCoreProject/**/*.csproj'
    configuration: ${{ parameters.buildConfiguration }} # Release
    arguments: -o drop-packages-dotnetcore

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…

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet publish command - .NET CLI
Name. dotnet publish - Publishes the application and its dependencies to a folder for deployment to a hosting system.
Read more >
net core - dotnet publish output folder?
The dotnet publish command published into the projects bin/netcoreapp2.2/Debug/publish folder. Where netcoreapp2.2 presumably changes with the ...
Read more >
Untitled
Dotnet publish output file name Web17 thg 3, 2020 · dotnet build to produce output assemblies. fetch certificate from Azure Keyvault. use ...
Read more >
In VS2019 v16.11.3 when publishing an old vb.net website ...
I have a simple publish profile with publish location bin\publish and delete existing files. I have seen previous work around suggested to add...
Read more >
Dotnet publish linux. Web"> <PropertyGroup> &l
Open a terminal window in Visual Studio Code and issue this command to publish the project: dotnet publish -o output-directory-name.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found