NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 250 forks source link

NullreferenceException at RestoreCommand.PerformAuditAsync(IEnumerable<RestoreTargetGraph> graphs, TelemetryActivity telemetry, CancellationToken token) #13526

Closed TFTomSun closed 2 weeks ago

TFTomSun commented 1 month ago

NuGet Product Used

NuGet SDK

Product Version

net48, net6

Worked before?

6.7.1

Impact

I'm unable to use this version

Repro Steps & Context

Executing the restore command fails since Version 6.8.0 - I tried with all newer versions, including the current preview 6.11.0-preview.2. It fails for net48 and net6 processes. But I assume it would also fail for net8.

In our enterprise environments nuget.config we use local sources (directories) and nuget sources pointing to a JFrog Artifactory instance.

Is that issue already known? Or should I provide more information.

The failing line is in NuGet.Commands.RestoreCommand.PerformAuditAsync: AuditUtility audit = new AuditUtility(_request.Project.RestoreMetadata.RestoreAuditProperties, _request.Project.FilePath, graphs, _request.DependencyProviders.VulnerabilityInfoProviders, _logger);

in _request.Project.RestoreMetadata.RestoreAuditProperties the RestoreMetadata property is null, maybe because of a missing source error that happened before, which was catched.

Verbose Logs

> NullReferenceException [0]: 
at NuGet.Commands.RestoreCommand.<PerformAuditAsync>d__72.MoveNext()
at NuGet.Commands.RestoreCommand.<ExecuteAsync>d__71.MoveNext()

dotnet --info
.NET SDK:
 Version:           8.0.200
 Commit:            438cab6a9d
 Workload version:  8.0.200-manifests.1850e762

Laufzeitumgebung:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.200\

Installierte .NET-Workloads:
Es sind keine installierten Workloads zum Anzeigen vorhanden.

Host:
  Version:      8.0.2
  Architecture: x64
  Commit:       1381d5ebd2

.NET SDKs installed:
  7.0.113 [C:\Program Files\dotnet\sdk]
  8.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.24 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.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
nkolev92 commented 1 month ago

@TFTomSun

Not really a known thing.

RestoreMetadata should be something that's always set.

Do you have any DotnetCliToolReference items in your projects by any chance?

If you don't have that, it'd be great if you can help us get a repro.

dotnet-policy-service[bot] commented 1 month ago

This issue has been automatically marked as stale because we have not received a response in 14 days. It will be closed if no further activity occurs within another 14 days of this comment.