Feature: Copy Packages from one source to another

Jul 14, 2011 at 6:46 PM
We've been having discussions about the work that we need to do to bring down packages from the official feed to our company feed.

I would like to see a command on the command line added to be able to copy packages from one source to another.

nuget.exe copy packageName [-source source] [-destination] destination [-version versionNumber]

Under the covers this:
  • combines two commands: nuget install && nuget push
  • additionally deletes the package locally when it has finished the push

As more and more companies start using nuget (possibly restricting the use of the official source) they may be looking for something like this.

Has anyone else started a discussion on this? Would anyone else find this to be useful?
Jul 14, 2011 at 6:53 PM

What am I missing? Couldn't you just copy the package down and save it to your local feed. This is essentially a network xcopy isn't it?

Jul 14, 2011 at 6:56 PM
Company Nuget gallery or even pushing to a HTTP Nuget.Server when you don't have access to the server locally.

A simple xcopy doesn't work when I can not \\someserver\someshare because it is blocked or on a different network.
Jul 14, 2011 at 6:59 PM

MyGet.org could benefit from this as well (or any NuGet.Server for that matter): we have a use case for archiving/mirroring packages from the official feed to any private feed. This IS a business requirement for lots of companies..

(FYI: MyGet already has the mirroring feature implemented, but supporting it in the NuGet commandline would be a great addition!)

Jul 14, 2011 at 6:59 PM

MyGet may benefit as well.

Jul 14, 2011 at 6:59 PM

I'm not saying literally using xcopy, I'm just saying isn't this a manual process of "Oh, there's a package I like". Find the .nupkg file. Right click. Save. Copy to local repository.

Jul 14, 2011 at 7:47 PM

Remember this is all standard HTTP. Not everything you want to do has to be built-in to NuGet.

You can use a tool like wget (http://gnuwin32.sourceforge.net/packages/wget.htm) to download the package file directly.

For example:

wget -c -N -P C:\Temp\packages http://packages.nuget.org/v1/Package/Download/elmah/1.2.0.1 

Here's a quick batch file you can use:

@echo off
setlocal
if "%2"=="" (
    echo USAGE: %0 PACKAGEID VERSION
    goto :eof
)

set repopath=C:\Path\To\Repo
set packageid=%1
set version=%2

wget -c -N -P %repopath% http://packages.nuget.org/v1/Package/Download/%packageid%/%version%

 

Developer
Jul 14, 2011 at 7:52 PM

I agree with Kiliman. I'm skeptical of baking everything into nuget. If the functionality can be easily automated with a simple script file, we should try not to add it to nuget.

Jul 14, 2011 at 8:00 PM

@kiliman: All you did there was get me the file. I still have a nuget push and delete the local file now.

Jul 14, 2011 at 8:02 PM

Thought I would throw this out into discussion.  Anything can be easily automated with a simple script file, but that hasn't kept simpler things out of nuget in the past. ;)

Jul 14, 2011 at 8:05 PM

Bill and Michael: I think you guys are a bit off on what I mean by destination.  This is not a local feed (although it could be). This is a nuget gallery or nuget server stood up somewhere that is NOT local to the machine.

It's :

nuget install castle.windsor

nuget push castle.windsor -source remoteFeed

rmdir castle.windsor

But it's still not that simple because we all know that would have brought dependent packages with it and I would have expected that they all got moved as well.

Jul 14, 2011 at 8:06 PM

Dang it, Bil not Bill. Sorry man.

Jul 14, 2011 at 8:07 PM

No worries. I do see where a feature would make sense because you need to grab dependencies but still I can a batch file or even PowerShell doing this pretty easily.

Jul 14, 2011 at 8:10 PM
ferventcoder wrote:

But it's still not that simple because we all know that would have brought dependent packages with it and I would have expected that they all got moved as well.

That's indeed something to take into account (which is something MyGet also takes care of ;-) )

Jul 14, 2011 at 8:13 PM

I'm not arguing the fact that we can script this out. I can script out changing the version in a nuspec file prior to building the package or people could manually change it prior to building. That feature made it into the command line version. I am not knocking the feature (thanks Joshua!) because it is useful for those that cannot script that idea out.

Does that make sense? The idea is useful for quite a few companies and as Xavier is eluding to, an absolute requirement for some companies who will remove the official feed.

Jul 14, 2011 at 8:14 PM

I'm asking if it would be useful to simplify the process as part of NuGet.

Jul 14, 2011 at 8:18 PM
Edited Jul 14, 2011 at 8:20 PM

Rob, I understand what you mean. The thing is I don't think NuGet has to be a Swiss-Army knife to be useful.

I see countless posts on here, Stackoverflow, Twitter, etc. where the person says, "Our process is such-and-such (usually something very specific), can NuGet support it?" Unfortunately they also say they won't change their process to fit NuGet either, usually ending in a snarky #fail. Sigh.

I wish NuGet had smaller, more focused commands in Core that could then be used to build higher level commands. Then new features could be built as Powershell commandlets, etc. instead of having to add more widgets. From my understanding, this is how Git was built. A bunch of low-level stuff that was hooked together to build really power features.

I look at the code now and it's getting more complex every day. And people continue to want more one-off solutions.

At the very least, creating script-based functions will be a proof-of-concept of how the feature should work and whether it would be useful to other people. If enough people like it, then it can be moved into the core.

Anyway, that's my 2 cents.

[edit: fixed typos]

Developer
Jul 14, 2011 at 8:40 PM

Totally agree with kiliman. This feature (although it seems nice) should be an extension that can be written and doesn't belong in core nuget. We support adding extensions to the command line in 1.4:

http://nuget.org/List/Packages/AddConsoleExtension

Jul 14, 2011 at 8:53 PM

While I can agree with the arguments against having this in core nuget, I think the exact same philosophy behind the very reason for nuget can be applied on such 'extended' commands.

People don't want to google with bing to find various scripts performing tasks with a tool that they find common practice.

Maybe something for a nuget package, extending the commandline built-in commands? :-)

Jul 14, 2011 at 9:01 PM

Sorry if I wasn't clear, but it was assumed that these "extensions" would be installed via NuGet.

We have some examples of this already. Like NuGetPowerTools and NuGetPackageUpdater which eventually made it's way into v1.4. A prime example of building functionality that will eventually move into the Core.

Jul 14, 2011 at 9:07 PM
kiliman wrote:

Sorry if I wasn't clear, but it was assumed that these "extensions" would be installed via NuGet.

We have some examples of this already. Like NuGetPowerTools and NuGetPackageUpdater which eventually made it's way into v1.4. A prime example of building functionality that will eventually move into the Core.

Thanks for clarifying, seems like a valid approach indeed.

Coordinator
Jul 14, 2011 at 9:09 PM

Perhaps it could be a command in the PS Helper library as well: http://nuget.codeplex.com/workitem/310

Jul 14, 2011 at 9:13 PM

@kiliman: I agree completely. I usually write my own and wait to see how many people would find something useful.

Sometimes you see me being a devil's advocate (questioning my own core ideas) and this is certainly an area where I am questioning this.

I'm not the guy that will throw the #fail out b/c everyone has different needs/concerns.

I am getting ready to go down this avenue for getting something working, just wanted to throw it out there to see if others are interested enough for me to work it in with nuget or outside. Makes sense to start most features outside. :D

 

@dfowler: Right on. Thought that feature was in for 1.4 but I haven't heard much on it yet. Any blog posts out there yet?

PS. I was confused by the package name at first since it is extending the command line & not the powershell console. ;)

Jul 14, 2011 at 9:36 PM

Found: Matt Hamilton has been posting on this concept (although not exact): http://matthamilton.net/nuget-for-plug-ins and http://matthamilton.net/nuget-with-mef

Jul 14, 2011 at 11:54 PM

Weird that you reference nuget.exe instead of nuget.core. Anyway, I have a testing version up. I haven't been able to test a remote push yet though.

http://nuget.org/List/Packages/nuget.copyextension

Jul 15, 2011 at 4:21 AM

Not sure if this is related, but sysinternals tools are available via webdav which makes them look like an smb share - e.g. http://live.sysinternals.com is available as \\live.sysinternals.com\

It seems like some of these replication scenarios would be simpler if the official nuget packages were available as a virtual, read-only share.

Jul 15, 2011 at 4:24 AM

Renamed it to http://nuget.org/List/Packages/nuget.copy.extension and push is now working.

Jul 15, 2011 at 4:25 AM

Explanation here: https://github.com/ferventcoder/nuget.copy.extension

Jul 15, 2011 at 4:43 AM
@jongalloway: You may be on to something as well. :D
Jul 15, 2011 at 9:38 AM

I did a blog post about the extensions for anyone interested. I didn't find much for documentation when I looked: http://devlicio.us/blogs/rob_reynolds/archive/2011/07/15/extend-nuget-command-line.aspx

Coordinator
Jul 15, 2011 at 4:46 PM

Would love it if you ported that blog post to our docs. http://docs.nuget.org/. If you don’t have time, may we have permission to blatantly rip off that content?

Jul 15, 2011 at 4:51 PM
You may blatantly rip it off. :D


On Fri, Jul 15, 2011 at 10:46 AM, Haacked <notifications@codeplex.com> wrote:

From: Haacked

Would love it if you ported that blog post to our docs. http://docs.nuget.org/. If you don’t have time, may we have permission to blatantly rip off that content?

Read the full discussion online.

To add a post to this discussion, reply to this email (nuget@discussions.codeplex.com)

To start a new discussion for this project, email nuget@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Developer
Jul 15, 2011 at 4:54 PM

I'm thrilled that someone finally found a use for the ConsoleExtension package!

Jul 15, 2011 at 4:56 PM
I've added this to the ASP.NET Daily Community Spotlight queue - should get it some more exposure.

On Fri, Jul 15, 2011 at 8:54 AM, pranavkm <notifications@codeplex.com> wrote:

From: pranavkm

I'm thrilled that someone finally found a use for the ConsoleExtension package!

Read the full discussion online.

To add a post to this discussion, reply to this email (nuget@discussions.codeplex.com)

To start a new discussion for this project, email nuget@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Jul 26, 2011 at 12:15 PM
It's there today! http://www.asp.net/ | http://ow.ly/i/eRMc - Thanks John!

By the way, I am working on copyTags as well and my next blog post will show how to do automated testing as well with nuget extensions.
____
Rob
"Be passionate in all you do"

http://devlicio.us/blogs/rob_reynolds
http://ferventcoder.com
http://twitter.com/ferventcoder


On Fri, Jul 15, 2011 at 10:56 AM, jongalloway <notifications@codeplex.com> wrote:

From: jongalloway

I've added this to the ASP.NET Daily Community Spotlight queue - should get it some more exposure.

On Fri, Jul 15, 2011 at 8:54 AM, pranavkm <notifications@codeplex.com> wrote:

From: pranavkm

I'm thrilled that someone finally found a use for the ConsoleExtension package!

Read the full discussion online.

To add a post to this discussion, reply to this email (nuget@discussions.codeplex.com)

To start a new discussion for this project, email nuget@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Read the full discussion online.

To add a post to this discussion, reply to this email (nuget@discussions.codeplex.com)

To start a new discussion for this project, email nuget@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com