如何使用Nuget.exe更新包

时间:2013-04-03 18:54:56

标签: nuget

对于我在.NET中的小样本项目(直接在命令行上构建而不使用Visual Studio),我想直接使用Nuget.exe来检索我需要的库,而不必在源存储库中提交它们。

我已经能够使用命令

安装它们
nuget install packages.config -o $destinationFolder

packages.config中指定所需的包(如Visual Studio中的Nuget)。 但是,我无法更新已安装的软件包。我试过用这个命令

nuget update packages.config -r $destinationFolder

Nuget.exe抱怨

unable to locate project file for '...packages.config'`.

我在互联网上搜索过,但我只在Nuget论坛中找到similar question而没有答案。

1 个答案:

答案 0 :(得分:6)

我已经阅读了Nuget项目中的相关源文件,并且我发现要成功更新Nuget.exe需要找到Visual C#/ Basic / F#项目。

然后我在文件夹中创建了一个空的csproj文件,我已经能够更新之前安装的软件包了。

我在https://github.com/edymtt/nugetstandalone做了一个小样本,展示了如何使用Nuget.exe安装和更新软件包。我还使用了一种解决方法来确保只有最新版本的库保存在文件夹中。

更新2013-04-06 14:20 UTC 我已更新示例,以展示如何使用-ExcludeVersion flag of the install command实现该目标。