Skip to content

Guard PublishDir exclusion against project root directory#53923

Merged
jjonescz merged 3 commits intodotnet:release/10.0.4xxfrom
jjonescz:53626-PublishDirSelf
Apr 23, 2026
Merged

Guard PublishDir exclusion against project root directory#53923
jjonescz merged 3 commits intodotnet:release/10.0.4xxfrom
jjonescz:53626-PublishDirSelf

Conversation

@jjonescz
Copy link
Copy Markdown
Member

When dotnet publish -o . is used, PublishDir resolves to the project directory. The glob exclusion then excludes all source files, producing an empty assembly. Add a condition to skip the exclusion when PublishDir equals the project directory.

Fixes #53626

When dotnet publish -o . is used, PublishDir resolves to the project
directory. The glob exclusion then excludes all source files, producing
an empty assembly. Add a condition to skip the exclusion when PublishDir
equals the project directory.

Fixes dotnet#53626

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an SDK default item globbing issue where dotnet publish -o . can make PublishDir resolve to the project directory, causing the DefaultItemExcludes glob to exclude all source items and produce an empty assembly.

Changes:

  • Add an MSBuild condition to avoid excluding $(PublishDir)/** when PublishDir is the project directory.
  • Add a regression test ensuring compile items are not excluded when PublishDir points at the project root.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
test/Microsoft.NET.Build.Tests/GivenThereAreDefaultItems.cs Adds a regression test for PublishDir == project root not excluding compile items.
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.targets Guards the PublishDir exclusion so it doesn’t wipe out default source items when publishing to ..

Comment thread test/Microsoft.NET.Build.Tests/GivenThereAreDefaultItems.cs
Copy link
Copy Markdown
Member

@baronfel baronfel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for doing this

@jjonescz jjonescz enabled auto-merge (squash) April 22, 2026 07:53
@jjonescz jjonescz disabled auto-merge April 22, 2026 11:23
@jjonescz jjonescz changed the base branch from release/10.0.3xx to release/10.0.4xx April 22, 2026 11:23
@jjonescz jjonescz merged commit d3d049c into dotnet:release/10.0.4xx Apr 23, 2026
28 checks passed
@jjonescz jjonescz deleted the 53626-PublishDirSelf branch April 23, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants