Search code examples
dependenciesnugetnuget-packagenuspecpackages.config

NuGet Pack: Ignore packages.config for dependencies and use .nuspec file instead


In my .nuspec file i list my dependencies as such

<dependencies>
  <dependency id="Some.Package" version="[1.0,2.0)" />
  ...
</dependencies>

However, when i pack my project, i get this message:

Found packages.config. Using packages listed as dependencies

I don't want this, i want to use my listed dependencies in the .nuspec file.

I realise that there is a setting developmentDependency can be used to ignore a package. But since this is potentially a lot of packages, it would make more sense to use the .nuspec file instead of packages.config

I am using NuGet.exe version 2.8 to pack.


Solution

  • It appears that you are trying to pack your .csproj file. By doing this, NuGet is not looking at your .nuspec file. That is why you are getting the message.

    Found packages.config. Using packages listed as dependencies

    Using the project file is just a shortcut. If you want to be more explicit about how you want your package created, including dependencies and what files to include, you will need to specify the .nuspec file in nuget pack.

    nuget pack Your.Library.nuspec