Skip to content

Make PackageBuilder.CalcPsmdcpName deterministic#7410

Draft
omajid wants to merge 1 commit into
NuGet:devfrom
omajid:deterministic-packagebuilder-psmdcpname
Draft

Make PackageBuilder.CalcPsmdcpName deterministic#7410
omajid wants to merge 1 commit into
NuGet:devfrom
omajid:deterministic-packagebuilder-psmdcpname

Conversation

@omajid
Copy link
Copy Markdown
Contributor

@omajid omajid commented May 23, 2026

Bug

Fixes: NuGet/Home#14916

Description

The order of input files can vary between nuget pack runs, specially if nuspec files use the ** glob when specifying <file> elements.

A simple workaround is to sort files before computing the hash of the file contents in nuget package for the psmdcp file name. This keeps the hash stable across nuget pack runs.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@omajid omajid requested a review from a team as a code owner May 23, 2026 21:07
@omajid omajid requested review from martinrrm and nkolev92 May 23, 2026 21:07
@dotnet-policy-service dotnet-policy-service Bot added the Community PRs created by someone not in the NuGet team label May 23, 2026
@johnny1494
Copy link
Copy Markdown

Bug

Fixes: NuGet/Home#14916

Description

The order of input files can vary between nuget pack runs, specially if nuspec files use the ** glob when specifying <file> elements.

A simple workaround is to sort files before computing the hash of the file contents in nuget package for the psmdcp file name. This keeps the hash stable across nuget pack runs.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests buscar órdenes
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.
    Rastrear mejor pagos en las órdenes de Instacar shopper
    Órdenes de de $40-50-60-70 oh más altas en órdenes

@omajid
Copy link
Copy Markdown
Contributor Author

omajid commented May 25, 2026

Alternatively, we can try and fix the nuspec glob-resolving code at

public static IEnumerable<SearchPathResult> PerformWildcardSearch(
to return in a deterministic order.

@Nigusu-Allehu Nigusu-Allehu self-assigned this May 28, 2026
using (var hashFunc = new Sha512HashFunction())
{
foreach (var file in Files)
foreach (var file in Files.OrderBy(f => f, new NormalizedPathComparer()))
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.

Any chance you can add a test for this?

An idea could be to have a nuspec with 2 different globs pointing to 2 different folders and files in them, run pack once, and then move the files around but keep the names so that the same net package is generated.

@omajid omajid force-pushed the deterministic-packagebuilder-psmdcpname branch from d031db4 to 88533da Compare June 2, 2026 03:10
@omajid omajid marked this pull request as draft June 2, 2026 03:11
@omajid omajid force-pushed the deterministic-packagebuilder-psmdcpname branch 3 times, most recently from 300e716 to 1f41056 Compare June 3, 2026 02:00
The order of input files can vary between nuget pack runs, specially if
nuspec files use the `**` glob when specifying `<file>` elements.

A simple workaround is to sort files before computing the hash of the
file contents in nuget package for the psmdcp file name. This keeps the
hash stable across nuget pack runs.

Fixes: NuGet/Home#14916
@omajid omajid force-pushed the deterministic-packagebuilder-psmdcpname branch from 1f41056 to 3f2ef17 Compare June 3, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PRs created by someone not in the NuGet team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use a deterministic order for files when calculating psmdcp hash

4 participants