Nuget.exe install does not update package.config (or .csproj)?

While trying to get a nuget build workflow running on Linux / mono, I noticed a strange thing.

Being on Linux, I cannot use the Visual Studio Visual Studio plugin or the Powershell console, but I have the nuget.exe command line utility. This utility has an “install” command that correctly extracts packages and puts them in the directory of my packages.

However, installing nuget.exe (unlike installing Visual Studio) does not update package.config with the packages added and does not add the project link to my .csproj. The latter is less important (I can do it manually), since package.config must contain recursive dependencies, and I cannot do it manually ...

Has anyone else tried to install new packages exclusively using nuget.exe or have any idea about this? Do I bark at the wrong tree?

+6
source share
2 answers

Like at the moment (Nuget 2.8.1), this is still not possible and is the main drawback of the nuget command-line client, as I see it.

Nuget.exe should be able to install the package and add it to packages.config with all the dependencies so that it can be used for anything more than the simplest cases.

I created a problem, see https://nuget.codeplex.com/workitem/4258

Bypass

Currently, you can use the following approach. Please note that it is far from optimal, but at least it allows you to correctly use nuget packages and allow dependent packages.

  • Manage packages.config manually. Add the packages you need, but leave their dependencies. Please note that this is different from the “regular” packages.config files, which also display dependencies.

  • Use a script to go through packages.config and issue nuget install <package-id> -Version <version> for each package. This will install the package and its dependencies.

+3
source

I think the best solution is to use the technique described here to create a PCM team that will install several packages at a time.

Here's a little proof of concept that copies the final command to the clipboard:

 param([string[]]$dependencies) $command = ""; foreach($dependency in $dependencies) { $name = $item.Name if($dependency) { $command += ('"{0}", ' -f $dependency) } } $command = $command.Substring(0, $command.Length - 2) + " | foreach {Install-Package `$_}" $command | Set-Clipboard 
0
source

Source: https://habr.com/ru/post/927922/


All Articles