Fix package source mapping keys in temp config file For packing-common #543
+126
−7
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.
Description
NuGet Package Source Mapping enforces that a package's declared source in must match a corresponding source name under .
The Azure Pipelines internal NuGet helper (NuGetConfigHelper2.ts) currently prefixes internal feed names with feed- when writing the temporary NuGet.config used during restore,
However, the helper does not update the section accordingly, leaving the mapping with the original key:
NuGet interprets this mismatch as a violation of Package Source Mapping rules and fails with:
📌 Bug 2340656: DotNetCoreCLI@2 breaks package source mappings for internal feeds when using a nuget.config file
Keeps existing feed prefixing untouched (feed- logic stays exactly as before).
Tracks original → prefixed feed names when internal sources are rewritten.
After the temp NuGet.config is generated, the fix:
Loads the XML,
Locates ,
Updates mapping keys to match their prefixed feed names, e.g.: canarytest → feed-canarytest
Writes back the corrected temporary config.
Package Name
packaging-common
Risk Assessment (Low / Medium / High)
Low - Only modifies temporary NuGet.config used during restore and doesnot modify prefixing logic or authentication logic.
Unit Tests Added or Updated
Additional Testing Performed
Tested Manually by uploading changes to private org - https://dev.azure.com/v-dmerugu0683/Sample%20Project/_build/results?buildId=1023&view=logs&j=4ef10708-f316-5e1d-20e0-afbca60c92cd&t=77245893-7256-55ca-6acf-ef97785d1a31

Documentation Changes Required (Yes / No)
yes - https://learn.microsoft.com/en-us/nuget/consume-packages/package-source-mapping
Related Issues
microsoft/azure-pipelines-tasks#21507
Checklist