Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nuget.exe install not updating packages.config (or .csproj)?

Tags:

c#

nuget

mono

While trying to get a nuget build workflow working on Linux/mono, I've noticed an odd thing.

Being on Linux, I cannot use the nuget Visual Studio plugin or the Powershell console, but I have the nuget.exe command-line utility. This utility has an "install" command which properly fetches packages and places them in my packages directory.

However, nuget.exe's install (as opposed to the Visual Studio install) doesn't appear to update packages.config with the packages it added, nor does it add project references to my .csproj. The latter is less important (I can do it manually), since the packages.config needs to contain recursive dependencies as well I can't do it manually...

Has anyone else tried to install new packages solely using nuget.exe or has any insight into this? Am I barking up the wrong tree entirely?

like image 437
Shay Rojansky Avatar asked Oct 17 '12 09:10

Shay Rojansky


People also ask

How do I update NuGet EXE?

Use nuget update -self on Windows to update an existing nuget.exe to the latest version. The latest recommended NuGet CLI is always available at https://dist.nuget.org/win-x86-commandline/latest/nuget.exe .

How do I force a NuGet package to reinstall?

Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.

How do I manually install a NuGet package?

Open your project or solution in Visual Studio, and select Tools > NuGet Package Manager > Package Manager Console to open the Package Manager Console window. In the console, enter Find-Package with a keyword to find the package you want to install.

How do I know if NuGet EXE is Installed?

In Visual Studio, use the Help > About Microsoft Visual Studio command and look at the version displayed next to NuGet Package Manager. Alternatively, launch the Package Manager Console (Tools > NuGet Package Manager > Package Manager Console) and enter $host to see information about NuGet including the version.


1 Answers

As it currently (Nuget 2.8.1) stands, this is still not possible and a major shortcoming of the nuget command line client, as I see it.

Nuget.exe must be able to install a package and add it to the packages.config with all dependencies to be usable for anything more than the most simple cases.

I have created an issue, see https://nuget.codeplex.com/workitem/4258

Workaround

For the time being, the following approach can be used. Note that it is far from optimal, but at least enables you to use nuget and resolve dependent packages correctly.

  1. Resort to managing the packages.config manually. Add the packages you need, but omit their dependencies. Note that this is different from "ordinary" packages.config files, which do list the dependencies as well.

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

like image 71
theDmi Avatar answered Sep 19 '22 09:09

theDmi