Scott Hanselman

NuGet Support for Visual Studio 2008

August 11, 2011 Comment on this post [12] Posted in NuGet | NuGetPOW
Sponsored By

macgyvertoolWell, not really. A better title would be "How to Cobble Together NuGet Support for Visual Studio 2008 with External Tools and a Prayer." The point is, there are lots of folks using Visual Studio 2008 who would like NuGet support. I'm exploring this area and there's a half-dozen ways to make it happen, some difficult and some less so. The idea would be to enable some things with minimal effort. It'll be interesting to see if there are folks in the community who think this is important enough to actually make it happen. Of course, the easiest thing is to just use 2010 as it sill supports .NET 2.0, 3.0, 3.5, and 4, but not everyone can upgrade.

Someone could:

  • Backport the existing NuGet Package References dialog to 2008 using that version's native extensions (not VSiX)
  • Create MEF (Managed Extensibility Framework) plugins for the nuget.exe command-line to update the references in a vbproj or csproj
  • Use PowerShell scripts and batch files to get the most basic stuff working (get a package and update references.)
    • Maybe write a shim to get DTE automation working...

But that's coulds and maybes. Let's talk about the MacGyver solution.

Launch Visual Studio 2008 and go to Tools | External Tools.

External Tools in Visual Studio

Make a new Tool with these values:

  • Title: NuGet Install
  • Command (I'm assuming this is in the PATH): nuget.exe
  • Arguments: install your.package.name -excludeversion -outputDirectory .\Packages
  • Initial directory: $(SolutionDir)
  • Use Output window: Checked
  • Prompt for arguments: Checked

Next, right click in the Tookbar area and create a new Toolbar called NuGet. From Commands, drag in the correct Tools | External Tool button. Right click it and design to taste:

Creating a new Toolbar with "NuGet Install" on it

Now, when you click Install Package, you should change your.package.name to whatever the you want is, and click OK. Note the output in the console window below.

NuGet in Visual Studio 2008

At this point, because we are only integrating the command line too, you don't get the references added automatically. And where's the packages? Well, they are here, one directory up under Packages. It's still up to you to add the reference yourself and make sure it's the appropriate one (I refer you again to the wish list above.)

The NuGet packages

If you are feeling extra fancy, you can even add a few macros and links in your Toolbar to send you to the NuGet site for searching.  Here's a Visual Studio 2008 macro that launches your default web browser and takes you to http://www.nuget.org/List/Packages.

Public Module NuGet
Sub LaunchNuGetSite()
Dim p As New System.Diagnostics.Process()
p.Start("http://www.nuget.org/List/Packages")
End Sub
End Module

Then make toolbar buttons for those extra buttons, like this one for going to the NuGet site and searching:

More buttons for NuGet

Thoughts, Dear Reader?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
August 11, 2011 3:48
Or use sharpDevelop 4.1beta...
worked for a few solutions that we tested
August 11, 2011 11:28
MacGyver AND code in the same post? I always hoped but never believed....
August 11, 2011 16:00
Looks to me not needed. Who wants to use VS2008 anyway these days? (Ok, my work forces me to use VS2008. That is not wanting).
August 11, 2011 22:13

Who wants to use VS2008 anyway these days?


Plenty of places are still using VS2005 or even VS6, so don't dismiss solutions for older editions of VS. True, those older editions may not be in use by Web developers, but they are still in use.
August 15, 2011 19:10
Or you can also use OpenWrap against the nuget server, as we happily support VS2008 :)
August 17, 2011 2:39
Hell, yes please. We MUST use VS2008 because VS2010 does not support .NET CF nor does it appear to have any plans ever to do so.

As NuGet (from rel 1.3) supports .NET CF it would be nice to have tooling support from Visual Studio 2008.
September 10, 2011 22:08
+1 for 2008 support.

I still can't stand to use 2010, dog slow pos. I hope they rewrite it again before I have to use it.
September 30, 2011 19:37
Microsoft VS2008 is still a very good development tool and has gotten most if not all of the serious bugs wrung out of it. The same is true about VS2010 with the small caveat that 2010 suffered from the shift to .NET V3.5 to 4.0 and the trouble adding support for MS Office2010/WCF/Sharepoint 2007&2010 ..

If you are still developing on a duo-core machine, with a 32-bit OS or with less that 6G of ram on a quad-core machine, then your VS2010 experience will NOT be a good one.

That said, Is anyone willing to start a codeplex project to develop a VS2008 Extension for NuGet?
January 31, 2012 1:04
Would be great to have NuGet on VS08 as lots of legacy stuff is still to be maintained and even developed against VS08
October 12, 2012 2:20
The very first step has this:
- Launch Visual Studio 2008 and go to Tools | External Tools.

Make a new Tool with these values:

* Title: NuGet Install
* Command (I'm assuming this is in the PATH): nuget.exe

Ah, the 3rd step "Command" has "assume" in there,.
OK, where are the "instructions" on getting NuGet put on the system in the *first* place before *ass-U-ME-ing"?

In short, McGyver, the detonator done triggered ages ago ... your finally done for.
December 05, 2012 6:31
Interesting post. Well, we use a mix of tools. Most of the current projects are VS2012 (10 if we need to). However, my current client is supporting a Windows CE project, that's VS2005, but the application that runs on it can only mature through VS2008. Perhaps Microsoft will find a way for VS2012 to support Smart Devices. Probably never VS2010. Not holding my breath in the meantime. Long story short, yes, we're "stuck" at VS2008 and .NET 3.5 (Compact Framework no less) for much of what we're doing. Only sometimes at the VS2012 with Nuget joy.
December 06, 2012 0:00
Why would I want to? I don't! But there does not appear to be another option to develop for the compact framework. So - nuget/macgyver proceed... But the latest nuget.exe does not appear to allow this hack: "Package restore is disabled by default. To give consent, open the Visual Studio Options dialog, click on Package Manager node and check 'Allow NuGet to download missing packages during build.' You can also give consent by setting the environment variable 'EnableNuGetPackageRestore' to 'true'." I tried setting an env variable to no avail :(
Et

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.