NuGet对Visual Studio 2008的支持

macgyvertool
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.

好吧,不是真的。 更好的标题是“如何通过外部工具和祷告NuGet对Visual Studio 2008的支持整合在一起。 ”重点是,很多使用Visual Studio 2008的人都希望获得NuGet支持。 我正在探索这一领域,有六种方法可以实现这一目标,其中有些困难,而有些则更少。 想法是以最小的努力实现某些功能。 有趣的是,社区中是否有人认为这很重要,足以使其真正实现。 当然,最简单的方法是仅使用2010,因为它支持.NET 2.0、3.0、3.5和4,但并不是每个人都可以升级。

Someone could:

有人可以

  • Backport the existing NuGet Package References dialog to 2008 using that version's native extensions (not VSiX)

    使用该版本的本机扩展(不是VSiX)将现有的NuGet程序包引用对话框回退到2008年
  • Create MEF (Managed Extensibility Framework) plugins for the nuget.exe command-line to update the references in a vbproj or csproj

    为nuget.exe命令行创建MEF(托管扩展框架)插件,以更新vbproj或csproj中的引用
  • Use PowerShell scripts and batch files to get the most basic stuff working (get a package and update references.)

    使用PowerShell脚本和批处理文件来获取最基本的信息(获取程序包并更新引用)。
    • Maybe write a shim to get DTE automation working...

      也许写一个垫片来使DTE自动化工作...

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

但这就是可能。 让我们谈谈MacGyver解决方案。

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

启动Visual Studio 2008并转到“工具” | 外部工具。

External Tools in Visual Studio

Make a new Tool with these values:

使用以下值制作一个新工具:

  • Title: NuGet Install

    标题: NuGet安装

  • Command (I'm assuming this is in the PATH): nuget.exe

    命令(我假设这在PATH中): nuget.exe

  • Arguments: install your.package.name -excludeversion -outputDirectory .\Packages

    参数:安装your.package.name -excludeversion -outputDirectory。\ Packages

  • Initial directory: $(SolutionDir)

    初始目录: $(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:

接下来,右键单击Tookbar区域并创建一个名为NuGet的新工具栏。 从命令中,拖入正确的工具| 外部工具按钮。 右键单击并设计以品尝:

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.

现在,当您单击“安装软件包”时,应将您的.package.name更改为所需的名称,然后单击“确定”。 注意下面的控制台窗口中的输出。

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.)

此时,由于我们也只集成了命令行,因此您不会自动添加引用。 包在哪里? 好吧,它们在这里,位于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.

如果您觉得自己特别花哨,甚至可以在工具栏中添加一些宏和链接,以将您发送到NuGet网站进行搜索。 这是一个Visual Studio 2008宏,它将启动您的默认Web浏览器,并带您到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:

然后为这些额外的按钮制作工具栏按钮,例如用于进入NuGet网站并搜索的按钮:

More buttons for NuGet

Thoughts, Dear Reader?

想法,亲爱的读者?

翻译自: https://www.hanselman.com/blog/nuget-support-for-visual-studio-2008

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值