Home: The specified source 'MySource' is invalid

Created on 13 Dec 2017  路  10Comments  路  Source: NuGet/Home

Details about Problem

I am trying to push packages to the VSTS package manager from the command line like this

nuget.exe push -Source "MySource" -ApiKey VSTS *.nupkg
But I am getting the following error

The specified source 'MySource' is invalid. Please provide a valid source.
Even though the source exists.

Any idea why it doesn麓t recognize MySource?

I am using TFS2018.

This worked in the beginning and multiple packages where pushed. I tried removing the source and adding a new source but the same problem occurs.

NuGet.exe
NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe):

nuget.exe - recommended latest v4.4.1
NuGet version (x.x.x.xxx):

2017, TFS2018
VS version (if appropriate):

Windows10
OS version (i.e. win10 v1607 (14393.321)):

Yes, it worked before. Please rename the nugetworked.zip to nugetworked.exe for the executive file. Not sure which version it is because I downloaded it from the visual studio GUI wizard.
nugetworked.zip

Worked before? If so, with which NuGet version:

Detailed repro steps so we can see the same problem

1.

2.

...

Other suggested things

Verbose Logs

Please include verbose logs (NuGet.exe -verbosity detailed | dotnet.exe --verbosity diag | etc...)

Sample Project

Very helpful if you can zip a project and paste into this issue!

Investigate

Most helpful comment

Hi @emgarten sorry but I just realized why this didn麓t work. Kind of stupid but I forgot to add the source after recreated the feed :s
nuget.exe sources Add -Name "MySource" -Source "https://mydomain/tfs/DefaultCollection/_packaging/MySource/nuget/v3/index.json"

After this command I was able to upload as usual :)

All 10 comments

@doorman02 there isn't enough information here for me to be able to determine why your private feed isn't working.

Would you try debugging nuget.exe here https://github.com/NuGet/NuGet.Client/blob/95db8c8f61bc2b1dacfb541b0d665bd3cc9211f4/src/NuGet.Clients/NuGet.CommandLine/Commands/PushCommand.cs#L54 and share why the source is failing?

Hi @emgarten could you explain further, should I install the Nuget.Client in Visual Studio and run the command from there? Is there a c# code example I can use to get me up and running quickly? Thanks!

Try these instructions for cloning nuget.client: https://github.com/nuget/home/

Then open in VS 2017 and run the NuGet.Commandline project using your own parameters.

Hi @emgarten thanks for your quick reply. I cloned the project but when I build I get

Error CS0234 The type or namespace name 'ProjectSystem' does not exist in the namespace 'Microsoft.VisualStudio' (are you missing an assembly reference?)

I am using Visual Studio 2017.

@doorman02 try running build.ps1 first

Hi @emgarten I ran build.ps1 and when I build I get The type or namespace name 'ImageMoniker' could not be found (are you missing a using directive or an assembly reference?) NuGet.PackageManagement.UI C:\Users\myuser\Documentsnuget\srcNuGet.ClientsNuGet.PackageManagement.UI\Models\PackageIconMonikers.cs

It's a bit strange that the command line doesn't output more specific error message so I wouldn't need to compile the whole Nuget project :)

Not sure why you would get the ImageMoniker error, but if possible you can ignore it as nuget.commandline does not depend on NuGet.PackageManagement.UI

Hi @emgarten this worked and I was able to debug. The exception and innerexception give the same error message

The specified source 'MySource' is invalid. Please provide a valid source

Here is the trace

   at NuGet.Commands.PackageSourceProviderExtensions.ValidateSource(String source) in C:\Users\MyUsername\Documents\nuget\src\NuGet.Core\NuGet.Commands\Utility\PackageSourceProviderExtensions.cs:line 52
   at NuGet.Commands.PackageSourceProviderExtensions.ResolveSource(IEnumerable`1 availableSources, String source) in C:\Users\MyUsername\Documents\nuget\src\NuGet.Core\NuGet.Commands\Utility\PackageSourceProviderExtensions.cs:line 23
   at NuGet.Commands.PackageSourceProviderExtensions.ResolveAndValidateSource(IPackageSourceProvider sourceProvider, String source) in C:\Users\MyUsername\Documents\nuget\src\NuGet.Core\NuGet.Commands\Utility\PackageSourceProviderExtensions.cs:line 40
   at NuGet.Commands.CommandRunnerUtility.ResolveSource(IPackageSourceProvider sourceProvider, String source) in C:\Users\MyUsername\Documents\nuget\src\NuGet.Core\NuGet.Commands\Utility\CommandRunnerUtility.cs:line 27
   at NuGet.Commands.PushRunner.<Run>d__0.MoveNext() in C:\Users\MyUsername\Documents\nuget\src\NuGet.Core\NuGet.Commands\CommandRunners\PushRunner.cs:line 29
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at NuGet.CommandLine.PushCommand.<ExecuteCommandAsync>d__28.MoveNext() in C:\Users\MyUsername\Documents\nuget\src\NuGet.Clients\NuGet.CommandLine\Commands\PushCommand.cs:line 79
.

Thanks for your help!

Hi @emgarten sorry but I just realized why this didn麓t work. Kind of stupid but I forgot to add the source after recreated the feed :s
nuget.exe sources Add -Name "MySource" -Source "https://mydomain/tfs/DefaultCollection/_packaging/MySource/nuget/v3/index.json"

After this command I was able to upload as usual :)

Was this page helpful?
0 / 5 - 0 ratings