Skip to content

Fix content publish path calculation#52731

Merged
marcpopMSFT merged 3 commits intodotnet:mainfrom
JanKrivanek:dev/jankrivanek/content-pub-fix
Jan 29, 2026
Merged

Fix content publish path calculation#52731
marcpopMSFT merged 3 commits intodotnet:mainfrom
JanKrivanek:dev/jankrivanek/content-pub-fix

Conversation

@JanKrivanek
Copy link
Member

@JanKrivanek JanKrivanek commented Jan 29, 2026

Fixes dotnet/aspnetcore#65247

Thanks to @rainersigwald and @baronfel for quick analysis and rootcausing of the issue!

Context

The path was incorrecftly calculated from DefiningProjectDirectory - which can point to sdk targets. The relative paths should be allways based on MSBuildProjectDirectory which points to the user project file.

Testing

Was done manualy offline.

wsl -d Ubuntu -- bash -c "mkdir -p /home/jan/MVCFS && cd /home/jan/MVCFS && ~/dotnet10-200/dotnet new mvc -lang F# --no-restore"

wsl -d Ubuntu -- bash -c "cd /home/jan/MVCFS ; ~/dotnet10-200/dotnet publish"

To repro the behavior, you need project with CopyToPublishDirectory items, while it is being placed to more shallow folder nesting than the sdk that is being tested.

@JanKrivanek JanKrivanek requested review from a team as code owners January 29, 2026 10:54
Copilot AI review requested due to automatic review settings January 29, 2026 10:54
Copy link
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 incorrect publish TargetPath computation for Content items that only specify CopyToPublishDirectory, ensuring relative paths are consistently calculated from the user project directory instead of an SDK/imported targets directory.

Changes:

  • Replaced DefiningProjectDirectory-based relative path computation with $(MSBuildProjectDirectory) for Content items with publish-only metadata.
  • Simplified conditional logic into a single path computation branch.
  • Added an inline comment explaining why DefiningProjectDirectory is not reliable here.

@baronfel
Copy link
Member

This fix looks correct to me, but we'll need to backport to release/10.0.2xx when merged. @tmat the failing tests in CI are all under the dotnet-watch helix work item, and I can't seem to get any kind of output from azdo about them. How do you normally diagnose watch failures when they are reported in the pipelines?

@marcpopMSFT
Copy link
Member

/ba-g known watch test timeout

@marcpopMSFT
Copy link
Member

@baronfel link to the watch test issue: #52576 I have disabled in other branches already.

@marcpopMSFT marcpopMSFT merged commit c6b6cf2 into dotnet:main Jan 29, 2026
21 of 26 checks passed
@marcpopMSFT
Copy link
Member

/backport to release/10.0.2xx

@github-actions
Copy link
Contributor

Started backporting to release/10.0.2xx (link to workflow run)

@marcpopMSFT
Copy link
Member

/backport to release/11.0.1xx-preview1

@github-actions
Copy link
Contributor

Started backporting to release/11.0.1xx-preview1 (link to workflow run)

@tmat
Copy link
Member

tmat commented Jan 29, 2026

How do you normally diagnose watch failures when they are reported in the pipelines?

You need to open the test logs. Unfortunately, the infra does not handle hanging tests well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linux] Failed to publish MVC F# project with error MSB3021 "Unable to copy file ..."

6 participants