dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.66k stars 1.06k forks source link

Dotnet add package error: Value cannot be null. (Parameter 'path1') #15544

Closed ri-ch closed 2 years ago

ri-ch commented 3 years ago

Attempting to add a nuget package to a new console application results in the error Value cannot be null. (Parameter 'path1').

Expected behaviour: Running dotnet add package Microsoft.Extensions.Configuration.Json works without any errors.

Actual behaviour: error: Value cannot be null. (Parameter 'path1')

Steps to reproduce:

  1. dotnet new console -o test -n Test
  2. cd test
  3. dotnet add package Microsoft.Extensions.Configuration.Json

Full error details: https://gist.github.com/ri-ch/695332bca4591515ea5de830b114bf2d

dotnet --info output: .NET SDK (reflecting any global.json): Version: 5.0.102 Commit: 71365b4d42

Runtime Environment: OS Name: ubuntu OS Version: 20.10 OS Platform: Linux RID: ubuntu.20.10-x64 Base Path: /usr/share/dotnet/sdk/5.0.102/

Host (useful for support): Version: 5.0.2 Commit: cb5f173b96

.NET SDKs installed: 3.1.405 [/usr/share/dotnet/sdk] 5.0.102 [/usr/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.11 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.11 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

sfoslund commented 3 years ago

From the detailed error message you provided:

error: NU3028: Package 'Microsoft.Extensions.Configuration.Json 5.0.0' from source 'https://api.nuget.org/v3/index.json': The author primary signature's timestamp found a chain building issue: UntrustedRoot: self signed certificate in certificate chain

This seems to be the real cause error, there was something going wrong with the package's certs. I'm not able to repro this issue, is it still happening for you?

qjones-analog commented 3 years ago

I just ran into this same issue (I think).

I executed "dotnet add package Microsoft.AspNetCore.Mvc" and ended with a couple of errors:

error: NU3028: Package 'System.ComponentModel.Annotations 4.7.0' from source 'https://api.nuget.org/v3/index.json': The repository countersignature's timestamp found a chain building issue: UntrustedRoot: self signed certificate in certificate chain
info : Package 'System.ComponentModel.Annotations 4.7.0' from source 'https://api.nuget.org/v3/index.json': Signature type: Repository
info : Package 'System.ComponentModel.Annotations 4.7.0' from source 'https://api.nuget.org/v3/index.json': nuget-v3-service-index-url: https://api.nuget.org/v3/index.json
info : Package 'System.ComponentModel.Annotations 4.7.0' from source 'https://api.nuget.org/v3/index.json': nuget-package-owners: aspnet, dotnetframework, Microsoft
info : Package 'System.ComponentModel.Annotations 4.7.0' from source 'https://api.nuget.org/v3/index.json': Verifying the repository countersignature with certificate: 
info :   Subject Name: CN=NuGet.org Repository by Microsoft, O=NuGet.org Repository by Microsoft, L=Redmond, S=Washington, C=US
info :   SHA1 hash: 8FB6D7FCF7AD49EB774446EFE778B33365BB7BFB
info :   SHA256 hash: 0E5F38F57DC1BCC806D8494F4F90FBCEDD988B46760709CBEEC6F4219AA6157D
info :   Issued by: CN=DigiCert SHA2 Assured ID Code Signing CA, OU=www.digicert.com, O=DigiCert Inc, C=US
info :   Valid from: 4/9/2018 8:00:00 PM to 4/14/2021 8:00:00 AM
info : Package 'Microsoft.AspNetCore.Mvc' is compatible with all the specified frameworks in project '/disk1/site_dotnetcore/src/Microsoft.AspNetCore.Authentication.ADIAuthHandler/Microsoft.AspNetCore.Authentication.ADIAuthHandler.csproj'.
error: Value cannot be null. (Parameter 'path1')

Edit: after reviewing the file, there's actually a long chain of info-info-info-error messages, similar to the above.

Before finding this issue, I tried blowing away my package cache, so the output after running my command is very long. I've thrown the entire output, from command to end, into dotnet_error.txt

FWIW I'm on Gentoo Linux, running version 5.0.200.

$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.200
 Commit:    70b3e65d53

Runtime Environment:
 OS Name:     gentoo
 OS Version:  
 OS Platform: Linux
 RID:         gentoo-x64
 Base Path:   /opt/dotnet_core/sdk/5.0.200/

Host (useful for support):
  Version: 5.0.3
  Commit:  c636bbdc8a

.NET SDKs installed:
  3.1.406 [/opt/dotnet_core/sdk]
  5.0.200 [/opt/dotnet_core/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.12 [/opt/dotnet_core/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.3 [/opt/dotnet_core/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.12 [/opt/dotnet_core/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.3 [/opt/dotnet_core/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
nvborisenko commented 3 years ago

Clearing up nuget cache helped me to negotiate with expired certificate.

ghost commented 2 years ago

Thanks for creating this issue! We believe this issue is related to NuGet tooling, which is maintained by the NuGet team. Thus, we closed this one and encourage you to raise this issue in the NuGet repository instead. Don’t forget to check out NuGet’s contributing guide before submitting an issue!

If you believe this issue was closed out of error, please comment to let us know.

Happy Coding!