NuGet Support for Visual Studio 2008

Well, 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

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?

from hanselman

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值