Repository navigation
Description
Description
What happens
Verso's NuGet resolution omits individual packages that are declared as direct dependencies of packages Verso itself has already resolved. The omission is silent and deterministic: the package list shows the parent, but not the child.
Because the dropped package is never staged, it is invisible to both layers:
- the Roslyn compilation has no reference to it, so
usingits namespace fails with CS0234 - no assembly is staged for it, so the first runtime call into it fails with FileNotFoundException
The configuration this happens in
This is likely the key condition. The packages involved are NOT on any configured source. Only nuget.org is enabled in NuGet.Config; the packages are internal and reach the machine through earlier builds, so they exist only in the global packages folder (%USERPROFILE%.nuget\packages). Verso resolves 147 packages from there successfully - and drops three.
Verso's own error message for an unknown package confirms only nuget.org is consulted:
System.InvalidOperationException: Package 'Example.RootA' v26.31.1-alpha.1 was not
found on any configured source. Sources tried: https://api.nuget.org/v3/index.json
So this looks like a defect in the path that resolves from the global packages folder rather than in the download path. That also explains why I could not reproduce it with public packages: those come down from nuget.org through the normal path, which works.
Expected
Every package in the dependency closure is resolved and staged. If one is deliberately excluded or cannot be resolved, that should produce a warning naming the package and the reason, rather than surfacing later as a missing type or a missing assembly.
Evidence
Four root #r "nuget: ..." references resolve to 4 installed + 143 transitive packages, staged as 154 package/version entries in 147 package folders. I took all of them, read every dependency in their <group targetFramework="net10.0">, and checked it against the staged set. Ten declared dependencies are absent. Seven are framework-provided (Microsoft.Bcl.AsyncInterfaces, Microsoft.Extensions.FileSystemGlobbing, System.Buffers, System.Runtime.CompilerServices.Unsafe, System.Security.Principal.Windows, System.Text.Json, System.Threading.Tasks.Extensions) and are correctly dropped on net10.0.
The other three are ordinary library packages, and they are exactly the three assemblies that fail at runtime:
Example.MissingA 26.4.2 declared by Example.ParentA 26.31.1-alpha.1
Example.MissingB 26.4.2 declared by Example.ParentB 26.4.2
Example.MissingC 26.31.1-alpha.1 declared by Example.ParentC 26.31.1-alpha.1
All three parents are themselves resolved and staged.
The most telling detail: every direct dependency of all three dropped packages IS staged, at the exact version the dropped package declares. The walk appears to descend through these nodes and resolve their children correctly, while the nodes themselves never reach the output set.
What I ruled out
- The exclude attribute. All three are declared with exclude="Build,Analyzers" - but so are many packages that resolve correctly, all staged.
- The target framework group. For all three the dependency sits in the net10.0 group, not an older one.
- A packaging gap on our side. All three ship lib/net10.0 with the assembly the runtime asks for, and the assembly version matches the one in the exception.
- A stale or different .nuspec. The staged parent assemblies are byte-identical (SHA-256) to the global-packages copies whose .nuspec I read.
- Graph depth by shortest path. The three sit at depth 2 and 3; packages at depth 4 are staged.
- Graph depth by depth-first first-visit order. Simulating a DFS with a shared visited set puts the three at depth 7 and 8, while staged packages reach depth 13. No depth cutoff separates them.
- Nondeterminism. Two restores from a cleared staging folder produced byte-identical inventories (154 package/version entries in 147 packages, same three missing).
- A version conflict. Each of the three is requested by exactly one parent at exactly one version. Control packages that resolve correctly have the same shape.
- An unresolvable subtree. Every direct dependency of all three is staged, at the version declared.
- An incomplete cache entry. All three have .nupkg, .nupkg.sha512, .nuspec and extracted lib/net10.0 in the global packages folder, structurally identical to packages that resolve.
Where I suspect it sits
From the stack trace of an unrelated failure, the resolver is a custom recursive walker rather than NuGet's own:
Verso.Kernels.NuGetPackageResolver.DownloadSinglePackageAsync(
String packageId, String version, Int32 resolution, CancellationToken ct) line 329
Verso.Kernels.NuGetPackageResolver.ResolveWithDependenciesAsync(
String packageId, String version, List1 allPaths, List1 resolvedPackages,
HashSet`1 visited, Int32 depth, Int32 resolution, CancellationToken ct) line 235
Verso.Kernels.NuGetPackageResolver.ResolvePackageAsync(
String packageId, String version, CancellationToken ct) line 180
Consistent with that, Verso.Host.deps.json ships NuGet.Common, NuGet.Configuration, NuGet.Frameworks, NuGet.Packaging, NuGet.Protocol and NuGet.Versioning (all 6.9.1), but no NuGet.Resolver, NuGet.DependencyResolver.Core, NuGet.LibraryModel, NuGet.ProjectModel or NuGet.Commands, and no temporary project or project.assets.json is produced during restore.
Workaround, and why it is only partial
An AssemblyLoadContext.Resolving hook that probes the global packages folder (see Notebook Snippet) gets the notebooks running. Two limits:
- it does not fix CS0234 - the compilation still has no reference, so any
usingof a dropped package's namespace has to be removed - it only works because the missing DLLs are in the global packages folder. On a clean machine nothing would help: the packages are never fetched, since they are not in the resolved set.
There is also an ordering constraint: the hook must be registered in a cell AFTER the #r cell. In the same cell, the host has already resolved that submission's references by the time it runs.
Note on running the snippet
The staging folder is cumulative across notebooks and sessions. Run the snippet only right after a clean restore of a single notebook, otherwise packages another notebook referenced explicitly will mask the problem. In our cumulative folder (371 entries, 167 packages) the three do not show up, because another notebook references one of them directly via #r.
Not part of this report
Package names above are redacted. I could not identify what distinguishes these three from the 143 that resolve, so I could not rebuild the shape from public packages. The diagnostic in Steps to Reproduce and Notebook Snippet is generic and should surface the same class of defect on any graph that triggers it.
Steps to Reproduce
Environment: .NET 10 (net10.0), Verso 1.2.2, Windows.
Precondition that seems to matter: the packages are not available on any
configured source. Only nuget.org is enabled, and the packages in question are
not on it - they are present only in the global packages folder
(%USERPROFILE%.nuget\packages) from earlier builds. Verso still resolves them
from there, so the restore succeeds; it just drops some of them.
To reproduce with your own packages, the closest public equivalent should be:
restore a graph normally so the global packages folder is populated, then remove
or disable all package sources, clear the staging folder, and restore again.
I have not verified that this triggers it, but it matches the configuration here.
The staging folder is a machine-readable mirror of the resolution result: after a
restore, %TEMP%\verso-nuget-packages\net10.0-v2 holds exactly one folder per
resolved package and version, matching the notebook's "Installed Packages /
Transitive dependencies (N)" output one to one. That makes the bug observable
without reading any UI.
-
Move the staging folder aside so the next restore starts clean:
move "%TEMP%\verso-nuget-packages\net10.0-v2" "%TEMP%\verso-nuget-packages\run-1"
-
Restart VS Code - the host caches the resolution in memory.
-
Open one .verso notebook and run ONLY the package cell, nothing else, so the
staging folder reflects exactly this notebook's resolution. -
Run the snippet from the Notebook Snippet field in the next cell. It lists every
dependency declared in a staged package's net10.0 group that was not staged.Observed here: Example.ParentA 26.31.1-alpha.1 is staged, and its .nuspec
declares, inside the net10.0 group:Example.MissingA is not staged. Same shape for MissingB and MissingC.
-
Compile-time effect - in a cell:
using Example.MissingA.Sub;
-> CS0234
-
Runtime effect - instantiate something that calls into the dropped package:
var host = new AppHost(settings);
-> FileNotFoundException for Example.MissingA, Version=26.4.2.0
-
Repeat steps 1-4 and compare the two inventories. Here they were byte-identical,
so this is deterministic, not a race. -
Adding the dropped package as an explicit top-level reference fixes both errors:
#r "nuget: Example.MissingA, 26.4.2"
Error Output
Compile time, when using a namespace from a dropped package:
CompilationError
(11,21): error CS0234: The type or namespace name 'MissingA' does not exist in the
namespace 'Example' (are you missing an assembly reference?)
Runtime, on the first call into a dropped package:
System.IO.FileNotFoundException: Could not load file or assembly
'Example.MissingA, Version=26.4.2.0, Culture=neutral, PublicKeyToken=null'.
The system cannot find the file specified.
at Example.ParentA.ServiceCollectionExtension.AddThings(IServiceCollection services)
at AppHost.ConfigureServices(HostBuilderContext context, IServiceCollection services) in AppHost.cs:line 133
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at AppHost..ctor(AppSettings settings) in AppHost.cs:line 57
at Submission#1.<<Initialize>>d__0.MoveNext()
at Verso.Kernels.ScriptStateManager.RunAsync[T](Script`1 script, CancellationToken cancellationToken) in ScriptStateManager.cs:line 39
at Verso.Kernels.CSharpKernel.ExecuteAsync(String code, CancellationToken cancellationToken) in CSharpKernel.cs:line 226
For contrast - a package that is genuinely unavailable does throw, naming the
sources it tried. A transitive package that cannot be resolved appears to be
skipped silently instead:
System.InvalidOperationException: Package 'Example.RootA' v26.31.1-alpha.1 was not
found on any configured source. Sources tried: https://api.nuget.org/v3/index.json
at Verso.Kernels.NuGetPackageResolver.DownloadSinglePackageAsync(String packageId, String version, Int32 resolution, CancellationToken ct) in src/Verso/Kernels/NuGetPackageResolver.cs:line 329
at Verso.Kernels.NuGetPackageResolver.ResolveWithDependenciesAsync(String packageId, String version, List`1 allPaths, List`1 resolvedPackages, HashSet`1 visited, Int32 depth, Int32 resolution, CancellationToken ct) in src/Verso/Kernels/NuGetPackageResolver.cs:line 235
at Verso.Kernels.NuGetPackageResolver.ResolvePackageAsync(String packageId, String version, CancellationToken ct) in src/Verso/Kernels/NuGetPackageResolver.cs:line 180
at Verso.Kernels.CSharpKernel.ProcessNuGetReferencesAsync(String code, IExecutionContext context, CancellationToken ct) in src/Verso/Kernels/CSharpKernel.cs:line 427
at Verso.Kernels.CSharpKernel.ExecuteAsync(String code, IExecutionContext context) in src/Verso/Kernels/CSharpKernel.cs:line 147
Component
NuGet Package Resolution
Frontend
VS Code
Verso Version
1.2.2
.NET Version
10.0.301
Operating System
Windows 11
Notebook Snippet
// Standalone - no #r needed. Compares what Verso staged against what the
// staged packages declare for net10.0. Run right after a clean restore of a
// single notebook; the staging folder is cumulative otherwise.
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
var staging = Path.Combine(Path.GetTempPath(), "verso-nuget-packages", "net10.0-v2");
var cache = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget", "packages");
var staged = new List<(string Id, string Version)>();
foreach (var pkgDir in Directory.GetDirectories(staging))
foreach (var verDir in Directory.GetDirectories(pkgDir))
staged.Add((Path.GetFileName(pkgDir), Path.GetFileName(verDir)));
var stagedIds = new HashSet<string>(staged.Select(p => p.Id), StringComparer.OrdinalIgnoreCase);
Console.WriteLine($"staged: {staged.Count} package/version entries in {stagedIds.Count} packages");
// dependency ids in a nuspec's net10.0 group - plain string parsing, no extra reference
IEnumerable<string> Net10Deps(string text)
{
var at = 0;
while (true)
{
var start = text.IndexOf("targetFramework=\"net10.0\"", at, StringComparison.OrdinalIgnoreCase);
if (start < 0) yield break;
var end = text.IndexOf("</group>", start, StringComparison.OrdinalIgnoreCase);
if (end < 0) end = text.Length;
foreach (var part in text.Substring(start, end - start)
.Split(new[] { "<dependency" }, StringSplitOptions.None).Skip(1))
{
var i = part.IndexOf("id=\"", StringComparison.OrdinalIgnoreCase);
if (i < 0) continue;
i += 4;
var j = part.IndexOf('"', i);
if (j > i) yield return part.Substring(i, j - i);
}
at = end;
}
}
var missing = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (var (id, version) in staged)
{
var nuspec = Path.Combine(cache, id.ToLowerInvariant(), version.ToLowerInvariant(),
id.ToLowerInvariant() + ".nuspec");
if (!File.Exists(nuspec)) continue;
foreach (var dep in Net10Deps(File.ReadAllText(nuspec)))
if (!stagedIds.Contains(dep))
missing.Add($"{dep,-46} <- declared by {id} {version}");
}
Console.WriteLine($"declared net10.0 dependencies NOT staged: {missing.Count}");
foreach (var m in missing) Console.WriteLine(" " + m);Loaded Extensions
none
Severity
Medium - workaround exists but it's disruptive
Checklist
- I searched existing issues and this hasn't been reported yet
- I can reproduce this with no third-party extensions loaded
Activity
TorreyBetts commentedon Oct 1, 2026
Thanks for such a thorough report, it made this one much easier to track down. It turned out not to be about the global packages folder at all (Verso never reads it), it's how the dependency walk handled depth. The walk could first reach a parent at the end of a long chain, mark it visited, and then cut its dependencies off at a depth limit of six. The fix walks the graph one level at a time with no depth limit, so every package is reached along its shortest path. It's in #115 and will go out in the next release. Until then, the explicit
#rfor the missing packages is the cleanest workaround.