Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make it so the artifacts folders register files for cleanup #49595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

baronfel
Copy link
Member

Fixes #49582

The SDK knows that it's opting into Artifacts Path, and so the SDK can coordinate correcting the cleanup behavior for ArtifactsPath.

@Copilot Copilot AI review requested due to automatic review settings June 28, 2025 19:01
Copy link
Contributor

@Copilot 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

This PR updates the SDK to properly register files within artifacts folders for cleanup and provides accompanying tests.

  • Adds a test in ArtifactsOutputPathTests.cs to verify that published files (e.g., hostfxr.dll) are correctly cleaned up when building in Release configuration.
  • Updates the Microsoft.NET.DefaultOutputPaths.targets to include a new target _TrackFileWritesShareableUnderArtifactsPath ensuring file writes under both OutputPath and IntermediateOutputPath are tracked for cleanup.

Reviewed Changes

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

File Description
test/Microsoft.NET.Build.Tests/ArtifactsOutputPathTests.cs Adds tests to verify cleanup behavior for artifacts folders
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultOutputPaths.targets Enhances cleanup logic by tracking file writes under artifacts output directories

@dsplaisted
Copy link
Member

Instead of duplicating some MSBuild logic, would it make sense to update MSBuild so that (with an opt-in from the SDK) it would also look under the output and intermediate output paths in addition to the project directory?

@baronfel
Copy link
Member Author

That's also very reasonable, and much more clean. I can set that up for sure.

@baronfel
Copy link
Member Author

When dotnet/msbuild#12096 is merged, I'll update this to just set the new property (and keep the existing tests).

@baronfel baronfel marked this pull request as draft July 1, 2025 20:23
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.

"dotnet build" fails to produce a runnable binary if used after a self-contained publish with ArtifactsPath
2 participants