Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 29, 2025

Fixes issue where repositories using package source mappings would not have their packageSourceMapping section automatically updated when Maestro adds darc-* feeds.

Problem

When Maestro adds a darc-* feed to a repository's NuGet.config, it only updates the packageSources section but ignores the packageSourceMapping section. This causes NuGet restore failures in repositories that use package source mappings, as packages from the darc feeds are not mapped to their corresponding sources.

Solution

Modified the UpdatePackageSources method in DependencyFileManager to automatically populate package source mappings for darc feeds. The implementation:

  1. Preserves existing mappings: User-defined packageSourceMappings remain unchanged
  2. Uses Maestro-managed comments: Clearly separates auto-generated mappings from user mappings
  3. Leverages existing data: Uses the package-to-feed relationships already available from Version.Details.xml parsing
  4. Maintains idempotency: Multiple runs produce the same result without duplication

Example

Before (missing mappings cause restore failures):

<packageSourceMapping>
  <clear />
  <packageSource key="nuget.org">
    <package pattern="System.*" />
  </packageSource>
  <!-- darc feeds added to packageSources but not mapped here -->
</packageSourceMapping>

After (packages correctly mapped to darc feeds):

<packageSourceMapping>
  <clear />
  <!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
  <packageSource key="darc-pub-dotnet-corefx-4ac4c03">
    <package pattern="System.Collections.Immutable" />
    <package pattern="System.Text.Json" />
  </packageSource>
  <packageSource key="darc-pub-dotnet-standard-a5b5f2e">
    <package pattern="NETStandard.Library" />
  </packageSource>
  <!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
  <packageSource key="nuget.org">
    <package pattern="System.*" />
  </packageSource>
</packageSourceMapping>

Testing

  • Added comprehensive test case with realistic input/output files
  • All existing tests continue to pass (22/22)
  • Validated idempotency and backward compatibility
  • Tested integration with DARC CLI tool
Original prompt

This section details on the original issue you should resolve

<issue_title>darc-* auto-added feeds should come have auto-populated package source mappings</issue_title>
<issue_description>If a repo uses package source mappings, and Maestro is adding a darc-* feed, it should update the darc-* entry with the package source mappings.

Maestro knows what package IDs the darc* feed will contain, since it found which feed to add based on the packages IDs + versions listed in the Version.Details.xml.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #5318

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] darc-* auto-added feeds should come have auto-populated package source mappings Auto-populate package source mappings for darc-* feeds Sep 29, 2025
Copilot finished work on behalf of mmitche September 29, 2025 21:52
Copilot AI requested a review from mmitche September 29, 2025 21:52
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.

darc-* auto-added feeds should have auto-populated package source mappings

2 participants