profile
viewpoint

Ask questionsCan't use `dotnet add package` with a private repository (basic authentication)

Details about Problem

  • dotnet --version
    • 1.0.1
  • dotnet
    • 1.1
  • NuGet
    • 3.5.0.1996
  • MacOS Sierra
    • 10.12.4

Steps to reproduce

  1. Create a private NuGet repository (in my case using AppVeyor)
  2. Add it as a source:
nuget sources add -Name xxx -Source https://ci.appveyor.com/nuget/xxx -Username xxx@xxxx.com -Password xxx
  1. Prove that it's possible to list packages:
nuget list -s xxx
Using credentials from config. UserName: xxx@xxx.com
my.nuget.package 1.0.1

4 Attempt to add the private NuGet package to a dotnet project using the CLI:

dotnet add package -s https://ci.appveyor.com/nuget/xxx my.nuget.package

Expected

For the command to add the NuGet package to the project.

Actual

Got a message saying that it couldn't authenticate.

Microsoft (R) Build Engine version 15.1.548.43366
Copyright (C) Microsoft Corporation. All rights reserved.

  Writing /var/folders/v0/gv8rbbt9157g5599sh8qljpr0000gn/T/tmpz9doUg.tmp
info : Adding PackageReference for package 'my.nuget.package' into project '/Users/xxx/Documents/my.nuget.package/src/xxx/xxx.csproj'.
log  : Restoring packages for /Users/xxx/Documents/xxx/src/xxxLibrary/xxx.csproj...
info :   GET https://ci.appveyor.com/nuget/xxx/FindPackagesById()?id='my.nuget.package'
info :   Unauthorized https://ci.appveyor.com/nuget/xxx/FindPackagesById()?id='my.nuget.package' 4042ms
log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://ci.appveyor.com/nuget/xxx/FindPackagesById()?id='my.nuget.package''.
log  : Response status code does not indicate success: 401 (Unauthorized).
info :   GET https://ci.appveyor.com/nuget/xxx/FindPackagesById()?id='my.nuget.package'
info :   Unauthorized https://ci.appveyor.com/nuget/xxx/FindPackagesById()?id='xxx' 997ms
log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://ci.appveyor.com/nuget/xxx/FindPackagesById()?id='xxx'.
log  : Response status code does not indicate success: 401 (Unauthorized).
info :   GET https://ci.appveyor.com/nuget/xxx/FindPackagesById()?id='my.nuget.package'
info :   Unauthorized https://ci.appveyor.com/nuget/xxx/FindPackagesById()?id='xxx' 1007ms
error: Failed to retrieve information about 'my.nuget.package' from remote source 'https://ci.appveyor.com/nuget/xxx/FindPackagesById()?id='my.nuget.package''.
error:   Response status code does not indicate success: 401 (Unauthorized).
NuGet/Home

Answer questions arnotes

doesnt work when using global Nuget.config

dotnet v: 3.1.300 OS: Windows 10

useful!

Related questions

error NU1403: The package Microsoft.CSharp.4.0.1 sha512 validation failed. hot 2
NU3008: The package integrity check failed when installing System.Management.Automation 6.0.4. hot 1
dotnet add local package -> error: Value cannot be null. error: Parameter name: path1 hot 1
Implicitly Referenced by an SDK - Two of the same projects, one says this and the other does not. hot 1
NuGet pack "The DateTimeOffset specified cannot be converted into a Zip file timestamp" hot 1
Visual Studio 2015 with NuGet 3.6.0 fails to install packages with minClientVersion="3.6" hot 1
NU5012, nuget.exe pack cannot find built assemblies hot 1
Nuget MSBuild auto-detection picks up msbuild.exe from Microsoft SQL Server Data Tools for VS 201 hot 1
Skip Duplicate switch added to nuget.exe push command hot 1
Quote " characters in PATH cause "Illegal characters in path" failure in `nuget restore` hot 1
Floating package references don't get updated because of the no-op and http caches hot 1
RestoreSources set via MSBuild properties cannot use credentials hot 1
Microsoft.NET.Sdk.targets(129,5): error MSB4018: System.TypeLoadException: Could not load type of field 'Microsoft.NET.Build.Tasks.DependencyContextBuilder:_filteredPackages' (12) (expected class 'NuGet.Packaging.Core.PackageIdentity' in assembly 'NuGet.Packaging, Version=5.0.0.6) hot 1
NU5101 warning message repeats the recommendation hot 1
Nuget.exe sources add with -password "@foo" raises System.FormatException - Home hot 1
source:https://uonfu.com/
Github User Rank List