NuGet: pack command is NOT including nuget dependencies

后端 未结 5 766
孤独总比滥情好
孤独总比滥情好 2021-01-07 18:20

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 repos
5条回答
  •  [愿得一人]
    2021-01-07 19:03

    The dependencies were missing for me because I didn't have the *.nupkg files in the packages folder for all the packages I was using.

    This was pretty hard to track down, because the output of nuget pack looked like it was working:

    Found packages.config. Using packages listed as dependencies
    

    I had been using GitHub's Visual Studio .gitignore and only commented out the one line about "Package Restore" (because I wanted to commit my packages), but I should have commented out two. It should look like this:

    # NuGet Packages
    # *.nupkg
    # The packages folder can be ignored because of Package Restore
    # **/packages/*
    

    Thanks to Rick Mohr's answer for linking to the CodePlex work item 3097, where feiling explains how the packages folder is used:

    Since packages.config contains just a list of packages, and does not contain dependency relationship between those packages, nuget needs to access those package files to get the dependency info. That's why it needs to know the packages folder.

    The dependency information that feiling refers to is inside the *.nupkg files. Once I changed the .gitignore and committed all the missing *.nupkg files, my TeamCity build server was able to successfully create my NuGet package with the correct dependencies.

提交回复
热议问题