Fix package source mapping keys in DotNetCoreCLIV2 #21618
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.
Context
When using Package Source Mapping in DotNetCoreCLI@2, NuGet restore fails with:
NU1100: PackageSourceMapping is enabled, the following source(s) were not considered: feed-
Root cause:
The task automatically prefixes internal feed names to feed- in , but the original user‑provided section still references the unprefixed key.
This mismatch causes NuGet to reject the internal feed, resulting in restore failures.
Related Issues:
Azure Pipelines: DotNetCoreCLI prefix bug (#21507)
NuGet Source Mapping mismatch issues (#402)
📌 DotNetCoreCLI ADO Work Items
Task Name
DotNetCoreCLIV2
Description
This PR adds a task‑level fix that:
Keeps the existing feed‑prefixing logic (e.g., canarytest → feed-canarytest)
After credentials are applied and the temp NuGet.config is generated, the task:
Loads both:
Original NuGet.config
Temporary NuGet.config (with prefixed feed names)
Uses xml2js to parse these safely and structurally.
Matches feeds by URL
Rewrites keys in the temporary config to match their new prefixed names.
Example:
key="canarytest" → key="feed-canarytest"
Writes back a corrected temporary NuGet.config so that NuGet sees consistent source and mapping keys.
Risk Assessment (Low / Medium / High)
Low - Does not change prefixing logic, only ensures mapping consistency
Change Behind Feature Flag (Yes / No)
No
Tech Design / Approach
Documentation Changes Required (Yes/No)
Yes
Additional Testing Performed
Tested Manually - https://dev.azure.com/v-sanjayse/TestProject2/_build/results?buildId=483&view=results
Rollback Scenario and Process (Yes/No)
Checklist