如何在 Visual C # Express 中使用 NuGet?

当我使用 Visual C # 2010 Express 时,如何使用 NuGet 来添加库包引用?

在工具 > 扩展管理器中搜索 NuGet 时没有出现。

我下载了“ NuGet 软件包管理器”(。Vsix) ,但是当它提示我要集成到 Visual Studio 的哪个版本时,它只列出 Visual Web Developer Express 2010。没有显示 VisualC # Express。所以我想它可以在 VWD 中使用 Silverlight,但是我想在 WPF 中使用它。

其中一个文档页面将我链接到了 1.0 CTP 下载页面,其中包括命令行版本的 NuGet (最新版本中已经不存在了)。但是命令行版本似乎受到了损害——它似乎支持的唯一操作是构建一个用于分发的包; 它似乎不支持添加对库包的引用的命令。

有没有什么方法可以在 Visual C # Express 中使用 NuGet?

41854 次浏览

Update (9/12/2012): Good news: Visual Studio Express 2012 for Windows Desktop is now available (here), and it supports NuGet out of the box. Generally speaking, every edition of VS2012 now supports NuGet, so this limitation should be a thing of the past!


Original answer:

Microsoft signs NuGet in a way that allows it to work with VWD Express. Ideally, it would also be signed in a way that it works with C# Express (it may have to be a separate build). Unfortunately, we were not able to do this for the initial release (it's more of a challenge than you might think).

Going forward, we will try to enable this scenario. Feel free to file a bug on the NuGet site just to let others who are affected a chance to vote it up!

If you have VWD Express installed you can work around this as follows:

  1. Save and close your project in c# Express

  2. Open the project in VWD Express and use Nuget from there to add your packages

  3. Save your project and go back to c# Express

To install a package in visual studio c# express 2010 use the command line tool nuget.exe. Download nuget.exe from the nuget website add the path to the executable to the windows path environment variable, cd to a place you want you library to be then run it with the library name as an argument.

C:\Code\myprojectdir\myproject>nuget install CommandLineParser
Installing 'CommandLineParser 1.9.71'.
Successfully installed 'CommandLineParser 1.9.71'.

Then just add a reference to the appropriate version of the dll (ie 4.0), in visual studio c# 2010 using project->add reference->browse. Then build the project.

Visit this video: https://youtu.be/8DcANVHLE0o The way is: Download .exe file from nuget.org, and make a folder in %appdata% "NuGet", paste the exe file in the folder, after that open cmd, type cd (the folder adress), and type nuget install (package), the go in the package folder, lib, copy the dll file, and put it as Reference in visual basic