从命令行添加对 VS 项目包的 Nuget 引用 [英] Add Nuget reference to VS project package from command line

查看:44
本文介绍了从命令行添加对 VS 项目包的 Nuget 引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用某些命令行工具向现有 VS 项目(csproj 或 jsprox)添加 NuGet 引用?

Is it possible to add a NuGet reference to an existing VS project (csproj or jsprox) using some command line tool?

我需要使用 Install-Package 命令提供类似包管理器控制台的功能:PM>安装包

I would need a functionality like package manager console offers using Install-Package command: PM>Install-Package

推荐答案

NuGet.exe 不支持此操作.使用 NuGet.exe,您可以根据 packages.config 文件中的内容下载 NuGet 包.您还可以使用 NuGet.exe 更新来更新 NuGet 包并在项目文件中更新它们的引用.但是,您不能使用 NuGet.exe 来安装 NuGet 包,因此它会将所需的引用添加到项目文件中.

This is not supported with NuGet.exe. With NuGet.exe you can download the NuGet packages based on what is in the packages.config file. You can also update NuGet packages and have their references updated in the project file by using NuGet.exe update. However you cannot use NuGet.exe to install the NuGet package so it adds the required references to the project file.

Paket 支持它,但是如果您使用 Paket,则需要切换到使用 Paket适用于所有 NuGet 包,因为它有自己的引用 NuGet 包的方式,不包括使用 packages.config 文件.它也不支持 PowerShell 脚本.

It is supported with Paket however if you use Paket then you would need to switch to using Paket for all NuGet packages since it has its own way of referencing the NuGet packages which does not include using the packages.config file. It also does not support PowerShell scripts.

我查看了 从命令行安装 NuGet 包在 Visual Studio 之外使用 SharpDevelop 和一组 PowerShell 命令.这是一个概念证明,但不受支持,需要 SharpDevelop 的大部分可用.

I looked at installing NuGet Packages from the command line outside of Visual Studio using SharpDevelop and a set of PowerShell commands. This was a proof of concept but is not supported and requires most of SharpDevelop to be available.

这篇关于从命令行添加对 VS 项目包的 Nuget 引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆