Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a pure solution-level NuGet package

I want to create and distribute a NuGet package that when installed only installs solution-wide to the root packages-folder, referencing the package in the .NuGet\packages.config file.

I have found some information on the NuGet package format in regards to this topic already and according to NuGet FAQ this should be possible if one follow these guidelines:

What is the difference between a project-level package and a solution-level package?

A solution-level package has to be installed only once in a solution to be available for all projects in the solution. A project-level package must be installed separately in each project where you want to use it. For solution-level packages, NuGet doesn't change anything in a project, whereas in a project-level package it does. Typically, a solution-level package installs new commands that can be called from within the Package Manager Console window.

Another Suggested SO solution states that the above should have worked too.

Thing is, I can't get it this to work. I have verified that my package has no lib or content directories:

NuGet package contents

I have put all the files to distribute in the tools-folder in the package, including the init.ps1` script top run on install.

I am using Visual Studio 2015 and when I want to install the package:

  1. I first of all have to select a project to install to. I had expected not having to specify this, as it is supposed to be solution-wide. :/
  2. The init.ps1 script does run and executes the commands as I want them to do. :)
  3. But, a packages-folder is created in the project that I was forced to choose to get the installation done. I would have expected the packages-folder to be created in the solution-root. :(
  4. Also, the packages.config file is created in the project-folder and not in .NuGet\packages.config, as I'd expect after reading the docs I have found on this. :(

Any suggestions on how to get this working? Is this a VS 2015 limitation or a NuGet 3 change (as I believe it was included in VS2015)?

like image 203
Spiralis Avatar asked Oct 26 '15 17:10

Spiralis


People also ask

How do I use NuGet package manager for a solution?

To launch the NuGet Package Manager for a Solution, you can go to the context menu for the Solution and select “Manage NuGet Package…”: When you search and try to add a new package, you can now select the projects you want to install the package into.

How do I build a NuGet package in Visual Studio?

Building Your Package. Once you've created your .nuspec file, it's now time to build your package! Nuget.Org provides an application nuget.exe that is used to bundle your library into a Nuget package. You should already have this installed if you are using Visual Studio, or you can download it from nuget.org/downloads.

How do I create a nupkg file in NuGet?

nuget.exe pack -IncludeReferencedProjects -properties Configuration=Release Using these options, Nuget will create a.nupkg that includes any referenced packages and projects. The package filename is automatically created, using the format [package id]. [package version].nupkg

Does NuGet include all the files in the package?

Again, the generated.nuspec contains no explicit references to files in the folder structure. NuGet automatically includes all files when the package is created. You still need to edit placeholder values in other parts of the manifest, however. From an assembly DLL


1 Answers

The NuGet team deprecated solution level packages in NuGet 3.0.

There is a discussion about bringing them back in a way that is compatible with Visual Studio 2013 for a future version of NuGet.

like image 55
Matt Ward Avatar answered Oct 13 '22 23:10

Matt Ward