Fix default NuGet packages restore folder#15416
Fix default NuGet packages restore folder#15416eerhardt wants to merge 2 commits intomicrosoft:mainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15416Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15416" |
|
/backport to release/13.2 |
|
Started backporting to release/13.2: https://github.com/dotnet/aspire/actions/runs/23323572778 |
There was a problem hiding this comment.
Pull request overview
Updates RestoreCommand to use NuGet’s built-in settings resolution for the global packages folder instead of hard-coding ~/.nuget/packages, aligning behavior with NuGet defaults and config.
Changes:
- Replace hard-coded user-profile-based packages folder with NuGet settings-based resolution.
- Load NuGet configuration settings and compute the global packages folder via
SettingsUtility.
|
Re-running the failed jobs in the CI workflow for this pull request because 3 jobs were identified as retry-safe transient failures in the CI run attempt.
|
We shouldn't default to ~/.nuget/packages. Instead we should use NuGet defaulting logic. Fix microsoft#15399 Fix microsoft#15404
1ccd6b7 to
6c9c83a
Compare
Simplify the code to use the same patterns as NuGet.Client sources.
| var noNugetOrg = parseResult.GetValue(noNugetOrgOption); | ||
| var verbose = parseResult.GetValue(verboseOption); | ||
|
|
||
| // Validate that both nuget-config and sources aren't provided together |
There was a problem hiding this comment.
Why did we decide to change the behavior here? Not sure I follow.
| var packageSources = LoadPackageSources(sources, nugetConfigPath, workingDir, noNugetOrg, verbose); | ||
| // Resolve the default packages path from settings (env var, config, or ~/.nuget/packages). | ||
| // If --packages-dir is provided, RestoreArgs.GlobalPackagesFolder overrides this. | ||
| var defaultPackagesPath = SettingsUtility.GetGlobalPackagesFolder(settings); |
There was a problem hiding this comment.
NIT: Above we are printing packagesDir for verbose logging but we are not printing defaultPackagesPath which will be the one we want most of the time.
| AllowNoOp = false, | ||
| GlobalPackagesFolder = packagesDir | ||
| GlobalPackagesFolder = packagesDir, | ||
| MachineWideSettings = new XPlatMachineWideSetting(), |
There was a problem hiding this comment.
NIT: I believe you call this above, so perhaps we can just reuse.
|
Left some minor feedback but this looks good otherwise. |
We shouldn't default to ~/.nuget/packages. Instead we should use NuGet defaulting logic.
Refactor the restore code using the patterns from the NuGet.Client sources. This simplifies the code.
Fix #15404