NuGet Package Manager Console tip

I love NuGet – I find it a very productive way to add and update references. Being able to package up files as well as references is great when you write custom ASP.NET MVC validators that you want to share, as you often want to share an assembly and the script file for the client-side validator. And for someone that likes the keyboard as an input mechanism, the Package Manager Console window works nicely. (Although I’d love it if someone could assign it a default shortcut key :-))

But aside from all of that, I love that the Package Manager Console (PMC) window essentially gives me PowerShell inside of Visual Studio. One of these days I’ll even write up some of the adventures that I’ve had with it :-)

I was recently creating a NuGet package and I put them into a local folder while testing. I add that folder to my package sources and then I can supply the –Source switch to Install-Package

Install-Package –Source NugetTest mypackage

However, I’ve rebuilt my laptop since I last set that up and the NuGetTest source wasn’t registered. Normally at this point I’d crack open the Nuget options as add it. For some reason, this time I just tried putting the path into the source… and it worked!

Install-Package –Source c:\NugetTest mypackage

You’re potentially underwhelmed, but it just hadn’t occurred to me to try this! A couple of days later I was adding Glimpse to a web project that uses Azure Table Storage and remembered that I’d seen a tweet from Maarten Balliauw about a preview package for Windows Azure. This package is on a MyGet feed and I was about to add a new feed in Visual Studio but decided to try the same trick:

Install-Package –Source https://www.myget.org/F/glimpse-windowsazure/ glimpse.windowsazure.storage

There are definitely times where adding the package feed is a good idea (e.g. when you’re going to use it a number of times), but I like that I can simply specify adhoc feeds without adding them.

Apologies if this is something you already knew – it was news to me!

Comments

  • Anonymous
    January 20, 2014
    I wasn't aware of it, too.