Skip to content

dotnet publish not same as publish from visual studio #39721

@rekna1

Description

@rekna1

Describe the bug

When you publish a project using dotnet publish /p:PublishProfile=FolderProfile it doesn't behave the same as publish from Visual Studio which is very confusing for ci/cd scenario's.

Some examples are:

  • If you specify a publishdir in the publish profile, dotnet publish ignores, I have to explicity specify it on the commandline with the -o parameter.

  • If in my csproj contains <Target Name="RenameConfigOnPublish" AfterTargets="Publish"> it works only with dotnet publish if I also specify <IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled> in the csproj, while this is not needed from visual studio.

  • If the publish profile contains <DeleteExistingFiles>true</DeleteExistingFiles> it seems to be ignored by dotnet publish, when publishing from Visual studio this runs fine. As far as I know there is even no commandline option to delete all files prior to publish

To Reproduce

see the examples in the description.

Further technical details

.NET SDK:
Version: 8.0.202
Commit: 25674bb2f4
Workload version: 8.0.200-manifests.8cf8de6d

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.202\

.NET workloads installed:
There are no installed workloads to display.

Host:
Version: 8.0.3
Architecture: x64
Commit: 9f4b1f5d66

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions