Skip locked files in Clean task instead of prompting (build script) - #27781
Open
Guillermo López-Anglada (guillermooo) wants to merge 7 commits into
Open
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Guillermo López-Anglada (guillermooo)
marked this pull request as ready for review
August 6, 2026 22:48
Guillermo López-Anglada (guillermooo)
requested a review
from Justin Chung (jshigetomi)
as a code owner
August 6, 2026 22:48
Guillermo López-Anglada (guillermooo)
requested a review
from a team
as a code owner
August 6, 2026 22:48
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Before
--exclude .vs/PowerShell/v16/Server/sqlite3 doesn't exist.
--exclude src/Modules/nuget.config is not cleaned up.
--exclude nuget.config is not cleaned up.
You can verify that the nuget.config files are not cleaned up like so:
git clean -fdX
git ls-file -ico --standard-exclude | sls nuget.config
Therefore, the --exclude options have been removed because they are
no-ops.
Caveat: The sqlite3 file/folder may depend on the Visual Studio version.
If Visual Studio is open, depending on its state git clean may fail to
unlink files under the .vs\ directory and prompt interactively during
the build.
After
gi clean ... may return different sets of paths in subsequent calls:
git clean --dry-run -dX # some paths
git clean -fdX
git clean --dry-run -dX # more paths
git clean -fdX
git clean --dry-run -dX # empty
...therefore, we use a while loop.
If a file cannot be deleted, we skip it (and its directory).
Caveat: Using the -Verbose switch results in very slow cleaning.
After this change, files locked by VS don't cause the build script to
prompt the user.
Guillermo López-Anglada (guillermooo)
force-pushed
the
users/guillermo/build-script-clean
branch
from
August 6, 2026 22:59
d624163 to
063fa8e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Updates the build clean step to avoid git clean prompting (notably when Visual Studio holds locks) by switching to a PowerShell-driven deletion flow based on git clean --dry-run.
Changes:
- Added
CleanLenienthelper to iteratively collect paths fromgit clean --dry-run -dXand delete them via .NET APIs. - Replaced direct
git clean -fdX ... --exclude ...call withMeasure-Command { CleanLenient }.
Copilot started reviewing on behalf of
Guillermo López-Anglada (guillermooo)
August 6, 2026 23:46
View session
The problem doesn't seem to be that `git clean --dry-run` keeps returning paths, but rather that the following keeps returning paths: - git clean -fdX - git ls-files --ignore --standard-exclude --cached --others But the second command isn't used in the script so far and this was only noticed during debugging.
Guillermo López-Anglada (guillermooo)
force-pushed
the
users/guillermo/build-script-clean
branch
from
August 7, 2026 04:54
063fa8e to
651a2f7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Avoid
git cleanprompting during build when Visual Studio is open.PR Context
build.psm1 :: Start-PSBuild: Bad interaction between CLI and Visual Studio #27745Details
The Before data cleans less file system items.
The After data cleans more file system items.
Clean operation measurements follow based on
start-psbuild -Clean -PSModuleRestore -UseNuGetOrg, andstart-psbuild -Clean -PSModuleRestore -UseNuGetOrg -InformationAction continue(only After)Before
git cleanalways prints to the screen.After
No screen printing included because
Measure-Commandsuppresses it?Notes
The script says it must support Windows PowerShell, but it doesn't run?
The old implementation calls
git cleannaively, and residual files/directories are left behind. The new implementation cleans exhaustively.It might be possible to use
git ls-file --cached --others --ignore --exclude-standard, but the returned files are not obviously the same, and directory removal might require additional work. However, there would be less dumb string parsing than usinggit clean --dry-run.This is what happens now when a file cannot be cleaned:
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header