Repository navigation
Description
NuGet Product Used
NuGet.exe, MSBuild.exe
Product Version
Observed with NuGet 6.13 during MSBuild restore on Windows. The same unfiltered loop is present in NuGet.Client dev at commit 0d428c0305148200b0a6f20fe4065e5bb58f3fdb.
Worked before?
No
Impact
It's more difficult to complete my work
Repro Steps & Context
NoOpRestoreUtilities.GetRestoreOutput iterates every entry in lockFile.Libraries and passes its name and version to GetPackageFiles, without filtering by library type. This includes entries explicitly marked type: project.
GetPackageFiles then checks for <id>.<version>.nupkg.sha512 and, if absent, .nupkg.metadata under the global-packages directory and configured fallback folders.
Public source:
Minimal scenario for reproducing the probes
The names below are synthetic. A demand-loaded filesystem is not required to inspect the unnecessary probes.
-
Create two SDK-style class-library projects,
ProbeConsumerandProbeLibrary, with aProjectReferencefrom the consumer to the library. Set the library's<Version>to2.3.4. Do not add a package dependency namedProbeLibrary. -
Force a restore of the consumer with a dedicated global-packages directory:
dotnet restore .\ProbeConsumer\ProbeConsumer.csproj --force --packages .\probe-packages
-
Confirm that the consumer's
project.assets.jsoncontainsProbeLibrary/2.3.4with"type": "project". -
Trace filesystem operations during restore, or instrument/break in
GetPackageFiles. The unfiltered loop passes the project identity to the package-marker checks, producing probes for:<global-packages>\probelibrary\2.3.4\probelibrary.2.3.4.nupkg.sha512 <global-packages>\probelibrary\2.3.4\.nupkg.metadata
The command above is a suggested standalone reproduction; the observed behavior was diagnosed in a larger restore and corroborated by the source path.
Expected behavior
Only package libraries should enter this package-marker collection loop. Project-reference libraries should not cause checks for package installation metadata. Existing handling of PackageDownload dependencies should remain unchanged.
Actual behavior and impact
Project-reference identities are also probed. On an ordinary local disk, missing markers are inexpensive. On a demand-loaded global-packages filesystem, these lookups can require remote work. In our read-through implementation, they can trigger unnecessary package acquisition, extraction, and publication when a project name/version happens to match a real feed package. Missing identities can also incur repeated remote lookup costs.
To be clear, NuGet is performing filesystem existence checks, not explicitly downloading project references. The acquisition side effect comes from the demand-loaded filesystem, and we have not observed project references being replaced by packages in dependency resolution. We have not quantified the overall restore-time improvement from removing these probes.
Suggested change
Filter the lockFile.Libraries loop in GetRestoreOutput to package libraries. Is there a compatibility reason for including project libraries here?
A regression test should cover a project library whose name/version also has package-marker files on disk, verifying that those markers are excluded while actual package libraries and PackageDownload dependencies remain included.
Related but distinct: NuGet/Home#14963 and NuGet.Client#7569 concern scanning other versions of actual packages, rather than probing project-reference identities.
Verbose Logs
No public trace attached. The relevant source path and synthetic reproduction scenario are provided above.
Activity
jebriede commentedon Nov 20, 2026
I reproduced this locally: restore checks for a
.nupkg.sha512file matching a project reference and records it inproject.nuget.cache, even thoughproject.assets.jsonidentifies the reference as a project.patschaefer commentedon Nov 20, 2026
I will raise a PR with a fix. I'm validating it now.