Fix SetupNugetSources.sh to avoid creating invalid XML comments when re-enabling disabled feeds #16207
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.
Problem
The script
eng/common/SetupNugetSources.shwas writing invalid XML comments when re-enabling disabled darc-int feeds in NuGet.Config files. When a disabled feed entry was already commented out, the script would create nested XML comments like:<!-- <!-- Reenabled for build : darc-int-dotnet-runtime-12345 --> -->This is not valid XML according to the XML specification (nested comments are not allowed), which causes NuGet to fail with parsing errors.
Root Cause
The script was replacing disabled entries with a comment:
This approach had two issues:
--) could create invalid comment sequences like-->Solution
Changed the script to simply delete the disabled entry line entirely, without adding any comment:
This approach:
Testing
Added a new test
ConfigWithCommentedOutDisabledDarcIntFeeds_RemovesEntriesAndProducesValidXmlthat specifically validates:All 26 tests pass, including manual verification with various edge cases (mixed disabled feeds, multiple darc-int feeds, special characters in feed names).
Fixes dotnet/source-build#5349
Original prompt
Fixes #16187
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.