Skip to content

Replace nuget-config packageSources while preserving mappings#58

Closed
travisbader wants to merge 1 commit into
Faithlife:masterfrom
travisbader:nuget-config-mapping
Closed

Replace nuget-config packageSources while preserving mappings#58
travisbader wants to merge 1 commit into
Faithlife:masterfrom
travisbader:nuget-config-mapping

Conversation

@travisbader
Copy link
Copy Markdown
Contributor

@travisbader travisbader commented May 21, 2026

The nuget-config convention replaced the entire nuget.config file on any mismatch. Repos that have a <packageSourceMapping> section (required when using Azure Artifacts) would have it silently destroyed every time the convention ran.

This came up in the LogosCompilerService repo: https://github.com/LogosBible/LogosCompilerService/blob/master/nuget.config

Why not just bake all mappings into the convention?

We could as an alternative approach, but it would introduce quite a bit of noise about unrelated dependencies across all our repos. There are many different private packages.

  • LogosCompilerService: OrdersApi.*, RoyaltyApi.*, Argus.*
  • AcademicProgramApi: AccountingApi.*, titanic, Faithlife.AiApi.*
  • ProclaimServices: Proclaim.*, ProclaimSignalR.*, SubscriptionsApi.v1.Client

What changed

convention.ps1 — Instead of a byte-for-byte file comparison and full replacement, the convention now uses XmlDocument to compare and replace only the <packageSources> element. All other sections (<packageSourceMapping>, <activePackageSource>, etc.) are left untouched.

files/nuget.config — The published template now includes <clear /> and the Faithlife Azure Artifacts feed.

Why <clear />?

Without <clear />, NuGet inherits any machine-level or user-level package sources configured in global NuGet.config files. This can cause builds to resolve packages from unexpected sources, making builds non-reproducible across machines. <clear /> ensures only the explicitly listed sources are used.

Previously the convention replaced the entire file, which destroyed
repo-specific packageSourceMapping entries. The new behavior uses
XmlDocument to surgically replace only the packageSources element,
leaving all other sections (packageSourceMapping, activePackageSource,
etc.) intact. Also adds <clear /> and the Faithlife Azure feed to the
published template so repos start with the correct baseline.
@travisbader travisbader changed the title nuget-config: surgically replace packageSources, preserve mappings Surgically replace nuget-config: packageSources while preserving mappings May 21, 2026
@travisbader travisbader marked this pull request as ready for review May 21, 2026 02:45
@travisbader travisbader changed the title Surgically replace nuget-config: packageSources while preserving mappings Surgically replace nuget-config packageSources while preserving mappings May 21, 2026
@travisbader travisbader changed the title Surgically replace nuget-config packageSources while preserving mappings Replace nuget-config packageSources while preserving mappings May 21, 2026
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's recommendation:

Without , NuGet inherits any machine-level or user-level package sources configured in global NuGet.config files. This can cause builds to resolve packages from unexpected sources, making builds non-reproducible across machines. ensures only the explicitly listed sources are used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate this because I can't use local package feeds. Strongly opposed.

@travisbader
Copy link
Copy Markdown
Contributor Author

travisbader commented May 21, 2026

@ejball can you please add me as an editor on this repo and take a look at this PR please. I suspect we may have omitted Faithlife Azure because we don't want it in a public repo, but I am unsure where it belongs if not here. Open to other / better ideas of how to approach this if you have them.

@travisbader
Copy link
Copy Markdown
Contributor Author

@travisbader travisbader deleted the nuget-config-mapping branch May 21, 2026 03:12
@bgrainger
Copy link
Copy Markdown
Member

Don't use package source mappings; just disable the NU1507 warning.

@travisbader
Copy link
Copy Markdown
Contributor Author

travisbader commented May 21, 2026

Don't use package source mappings; just disable the NU1507 warning.

So much simpler. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants