Install NuGet command line extensions using the Package Manager Console

1 minute read

It's quite late into the night over here, and the blog post is quite abstract, so please bare with me on this one :-)

While I was playing around tweaking and optimizing some things on my recently created NuGet.Analyze package, I actually found a way to install a NuGet command line extension from within the NuGet Package Manager Console. Basically, I'm just using some PowerShell scripts to automate the installation procedure.

I've wrapped it up in a package, and created a new cmdlet you all can use from now on: it's called *Install-CommandLineExtension. *To install it, simply install the NuGet.InstallCommandLineExtension package.

By default, it will also install a first command line extension that provides the same functionality from the command line. This one adds a new command addextension to the console. As you can see in the description of the addExtension package, it's instructing you with manual steps to get the thing installed, like this:

To use this package, install the package using NuGet.exe to %LocalAppData%\NuGet\Commands: *nuget.exe install -excludeversion -outputdir %LocalAppData%\NuGet\Commands AddConsoleExtension. *I actually ended up with a similar situation for my own extensions, and didn't feel very comfortable about that. Hence I kept looking for a solution I liked more and came up with this.

So in short: you'll be able to install extensions to the commandline, both from within the commandline as from within the package manager console now, just by installing this one single NuGet package.

Once this new cmdlet is available, you can simply extend you nuget command line as shown below:

If you intend to create your own NuGet Command Line extensions and publish them on the gallery, please use the 'ConsoleExtension' tag for your package. The extensions that are already available do this, and that allows you to very easily find those extensions in the gallery by using the following link: http://www.nuget.org/List/Search?searchTerm=tag%3A%20ConsoleExtension. Please give it a try and install any of those console extensions using this new cmdlet.

It just made my NuGet.Analyze.Installer package obsolete, and actually most likely all future installer packages that would have appeared for other extensions as well.

Hope this helps!

Leave a Comment