Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet: pack command is NOT including nuget dependencies

Tags:

i have the following setting:

  • nuget.exe Version: 1.6.21205.9031
  • Project A.csproj packaged into A.1.0.0.0.nupkg, and published to a LOCAL package repository hosted on my local IIS (My VS Nuget Extension i able to add the A-package to a new project)
  • Project B.csproj has a dependency to the A-package that i added with the VS Nuget Extension

Now, when i run

nuget spec 

the B.nuspec is created.

Then i run

nuget pack B.csproj -verbose 

but in the created B-package, their is NO dependency to the A-package. The nuget pack command tells me that it has found the packages.config file (which contains the dependency to the A-package), but then it says "Dependencies: None".

What am i missing? Could the problem be that the A-package can only be found in my local package repository? How can i make nuget.exe aware of this local repository?

Thanks a lot!

like image 623
Schweder Avatar asked Feb 23 '12 15:02

Schweder


People also ask

Does NuGet automatically install dependencies?

Install NuGet packages without dependenciesBy default, when installing NuGet packages, corresponding package dependencies will also be installed in your project. To avoid the installation of dependent packages, choose the Ignore Dependencies option in the Dependency behavior drop-down in NuGet Package Manager.

What is NuGet pack command?

Indicates that the built package should include referenced projects either as dependencies or as part of the package. If a referenced project has a corresponding . nuspec file that has the same name as the project, then that referenced project is added as a dependency.

How do I fix a missing NuGet package?

Enable package restore by choosing Tools > Options > NuGet Package Manager. Under Package Restore options, select Allow NuGet to download missing packages. In Solution Explorer, right click the solution and select Restore NuGet Packages.


2 Answers

nuget pack needs to be able to find the packages folder in order to resolve dependencies (see http://nuget.codeplex.com/workitem/3097), either in the same folder as the .csproj (as long as there's a .sln file one level above it) or in a folder specified in NuGet.Config.

like image 189
Rick Mohr Avatar answered Nov 11 '22 20:11

Rick Mohr


I think I may have figured this out...

Our library solution had Nuget Package Restore turned on. I turned off NuGet Package Restore, and after that the project dependences were included when I created the NuGet packages.

I'm not really sure why the dependencies were not included in the package when Package Restore was turned on, but oh well :).

like image 45
Kevin Tighe Avatar answered Nov 11 '22 20:11

Kevin Tighe