Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore fails with "The given key '0' was not present in the dictionary" #14167

Open
JanKrivanek opened this issue Mar 7, 2025 · 1 comment

Comments

@JanKrivanek
Copy link

NuGet Product Used

dotnet.exe

Product Version

9.0.200

Worked before?

Not sure

Impact

None

Repro Steps & Context

msbuild_binlog.txt

C:\tmp\trash\testProj\nunit> dotnet new nunit
The template "NUnit 3 Test Project" was created successfully.

Processing post-creation actions...
Restoring C:\tmp\trash\testProj\nunit\nunit.csproj:
C:\Program Files\dotnet\sdk\9.0.200\NuGet.targets(175,5): error : The given key '0' was not present in the dictionary.
Restore failed.
Post action failed.
Manual instructions: Run 'dotnet restore'

 C:\tmp\trash\testProj\nunit> dotnet restore
    C:\Program Files\dotnet\sdk\9.0.200\NuGet.targets(175,5): error : The given key '0' was not present in the dictionary.

Restore failed with 1 error(s) in 0.6s

Works OK in other paths

Verbose Logs

For more info - Binlog attached


> dotnet restore --verbosity diag
C:\Program Files\dotnet\sdk\9.0.200\MSBuild.dll -nologo -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\9.0.200\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\9.0.200\dotnet.dll -maxcpucount -target:Restore -tlp:default=auto -verbosity:m -verbosity:diag .\nunit.csproj
    Determining projects to restore...
    C:\Program Files\dotnet\sdk\9.0.200\NuGet.targets(175,5): error : The given key '0' was not present in the dictionary.

Restore failed with 1 error(s) in 0.6s

> dotnet --info
.NET SDK:
 Version:           9.0.200
 Commit:            90e8b202f2
 Workload version:  9.0.200
 MSBuild version:   17.13.8+cbc39bea8

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.200\

.NET workloads installed:
 [android]
   Installation Source: SDK 9.0.200
   Manifest Version:    35.0.39/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.android\35.0.39\WorkloadManifest.json
   Install Type:              Msi

 [ios]
   Installation Source: SDK 9.0.200
   Manifest Version:    18.2.9173/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.ios\18.2.9173\WorkloadManifest.json
   Install Type:              Msi

 [maccatalyst]
   Installation Source: SDK 9.0.200
   Manifest Version:    18.2.9173/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maccatalyst\18.2.9173\WorkloadManifest.json
   Install Type:              Msi

 [maui-tizen]
   Installation Source: SDK 9.0.200
   Manifest Version:    9.0.14/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maui\9.0.14\WorkloadManifest.json
   Install Type:              Msi

Configured to use workload sets when installing new manifests.

Host:
  Version:      9.0.2
  Architecture: x64
  Commit:       80aa709f5d

.NET SDKs installed:
  6.0.428 [C:\Program Files\dotnet\sdk]
  7.0.203 [C:\Program Files\dotnet\sdk]
  7.0.317 [C:\Program Files\dotnet\sdk]
  7.0.410 [C:\Program Files\dotnet\sdk]
  8.0.113 [C:\Program Files\dotnet\sdk]
  9.0.103 [C:\Program Files\dotnet\sdk]
  9.0.200-preview.0.25057.12 [C:\Program Files\dotnet\sdk]
  9.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
@jeffkl
Copy link
Contributor

jeffkl commented Mar 7, 2025

@JanKrivanek I think this is a duplicate of #14052 which has been fixed but not yet released. Can you verify that this command correctly displays an error instead of this unhandled exception?

dotnet restore -p:RestoreUseLegacyDependencyResolver=true

Your project, nunit, is referencing a package named NUnit and you should be getting an error about a cycle. Changing the name of your project will fix the issue.

@jeffkl jeffkl self-assigned this Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants