Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuget.exe add doesn't recognize named sources #8391

Open
asherber opened this issue Jul 28, 2019 · 3 comments
Open

nuget.exe add doesn't recognize named sources #8391

asherber opened this issue Jul 28, 2019 · 3 comments
Labels
Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Product:NuGet.exe NuGet.exe Type:Feature
Milestone

Comments

@asherber
Copy link

Details about Problem

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

NuGet version (x.x.x.xxx): 5.1.0.6013

dotnet.exe --version (if appropriate):

VS version (if appropriate):

OS version (i.e. win10 v1607 (14393.321)): win10 v1709 (16299.1217)

Worked before? If so, with which NuGet version: No

Detailed repro steps so we can see the same problem

  1. nuget sources add -name local -source c:\mypackages
  2. nuget add mypackage.nupkg -source local

At this point, I would expect to see mypackage.nupkg installed under c:\mypackages, but instead it's installed under a new directory called local under my current folder.

nuget list -source local returns no packages (because it's looking at the source named local)

Verbose logs

λ nuget add -source local mypackage.1.0.nupkg -verbosity detailed
NuGet Version: 5.1.0.6013
Acquiring lock for the installation of mypackage 1.0
Acquired lock for the installation of mypackage 1.0
Installing mypackage 1.0
Completed installation of mypackage 1.0
Successfully added package 'mypackage.1.0.nupkg' to feed 'local'.
@asherber
Copy link
Author

Looking closer at nuget add -help, I see that -source is supposed to take only the path, not the source name, so the current behavior is correct. I'm wondering, though, whether the command should be modified so that it can take a -name as well.

In my case, the actual path to the folder I'm using is fairly long and cumbersome to type, so it would be easier to refer to it with -name. (I know that I could also create a short local share to this folder, which would make it easier to type.)

@dominoFire dominoFire added this to the Backlog milestone Aug 2, 2019
@dominoFire
Copy link
Contributor

Thanks for your suggestion, @asherber

In the meantime, you can also use an environment variable to manage your local source. For example:

$env:NUPATH = "C:\path\to\packages\folder"
# Add package
nuget add -source $env:NUPATH mypackage.1.0.nupkg
# List packages
nuget list-source $env:NUPATH

@Stevie-O
Copy link

Looking through this, nuget help add does not specify the behavior if the folderBasedPackageSource refers to a path that does not exist. The OP's complaint suggests that, if it does not already exist, the path specified for folderBasedPackageSource is automatically created.

There seems to be two reasonable interpretations when folderBasedPackageSource does not exist:

  1. The user specified the correct path; therefore, the specified directory to be created automatically and the command processed normally
  2. The user specified an incorrect path; therefore, command processing should be aborted and a suitable error message presented to the user.

It seems to me that case #2 would be far more likely than case #1 for a command-line tool. Would it be preferable to raise an error if -source does not refer to an existing path, unless an additional option (such as -create) was also specified?

@nkolev92 nkolev92 added the Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. label Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Product:NuGet.exe NuGet.exe Type:Feature
Projects
None yet
Development

No branches or pull requests

6 participants