Skip to content

Error when using private MyGet feed and pre-authenticated url #424

Closed
@troyschneringer

Description

@troyschneringer

In my nuget config I've added a private myget feed:

<add key="[FEEDNAME]" value="https://www.myget.org/F/[FEEDNAME]/auth/[TOKEN]/api/v2" />

When I add a package from that feed in the project.json it doesn't resolve in Visual Studio. If I run a kpm restore it resolves against the pre-authenticated url successfully. It then attempts to resolve against the non-authenticated url 3 times, each failing with a 401 and ultimately failing the restore. Here's the output:

C:\source\src\[PROJECT] [master +0 ~2 -0]> kpm restore
Restoring packages for C:\source\src\[PROJECT]\project.json
  CACHE https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?Id='[PACKAGENAME]'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?Id='[PACKAGENAME]'
  GET https://www.myget.org/F/[FEEDNAME]/auth/[TOKEN]/api/v2/FindPackagesById()?Id='[PACKAGENAME]'.
  OK https://www.myget.org/F/[FEEDNAME]/auth/[TOKEN]/api/v2/FindPackagesById()?Id='[PACKAGENAME]' 49469ms
  GET https://www.myget.org/F/[FEEDNAME]/api/v2/package/[PACKAGENAME]/0.0.1.
Warning: DownloadPackageAsync: https://www.myget.org/F/[FEEDNAME]/api/v2/package/[PACKAGENAME]/0.0.1
  Response status code does not indicate success: 401 (Unauthorized).
  GET https://www.myget.org/F/[FEEDNAME]/api/v2/package/[PACKAGENAME]/0.0.1.
Warning: DownloadPackageAsync: https://www.myget.org/F/[FEEDNAME]/api/v2/package/[PACKAGENAME]/0.0.1
  Response status code does not indicate success: 401 (Unauthorized).
  GET https://www.myget.org/F/[FEEDNAME]/api/v2/package/[PACKAGENAME]/0.0.1.
Error: DownloadPackageAsync: https://www.myget.org/F/[FEEDNAME]/api/v2/package/[PACKAGENAME]/0.0.1
  Response status code does not indicate success: 401 (Unauthorized).
----------
System.ArgumentNullException: Value cannot be null.
Parameter name: stream
   at System.IO.Compression.ZipArchive..ctor(Stream stream, ZipArchiveMode mode, Boolean leaveOpen, Encoding entryNameEncoding)
   at Microsoft.Framework.PackageManager.PackageUtilities.<OpenNuspecStreamFromNupkgAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.Restore.NuGet.NuGetv2Feed.<OpenNuspecStreamAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.RemoteWalkProvider.<GetDependencies>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.RestoreOperations.<FindLibraryEntry>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.RestoreOperations.<CreateGraphNode>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.Framework.PackageManager.RestoreOperations.<CreateGraphNode>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.Framework.PackageManager.RestoreCommand.<RestoreForProject>d__62.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.RestoreCommand.<ExecuteCommand>d__61.MoveNext()
----------
Restore failed
Value cannot be null.
Parameter name: stream

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions