Search code examples
visual-studionugetnuget-packagenuspec

NuGet nuspec dependency - how to include a private NuGet gallery


Fixed - see Sara Lui's link to document in comments.

I have created several NuGet packages which are available on our private Corporate NuGet gallery.

Several of these packages are dependent upon one common package.

However, when I add this to my Nuspec file:

<?xml version="1.0"?>
<package >
  <metadata>
    ...
    <dependencies>
      <dependency id="MyCommonPackage" version="1.0">
      </dependency>
    </dependencies>
  </metadata>
</package>

Then it fails to install because it can't find "MyCommonPackage" - it's not looking for it in our corporate gallery:

NotFound https://api.nuget.org/v3-flatcontainer/MyCommonPackage/index.json

NotFound https://dotnetmyget.blob.core.windows.net/artifacts/roslyn/nuget/v3/flatcontainer/MyCommonPackage/index.json

Visual Studio has this gallery referenced, but I suspect I need to reference it in the nuspec file (just not seeing how to do this).


Solution

  • I fixed it by referring to link provided by @Sara Lui:

    please check this doc: https://learn.microsoft.com/en-us/nuget/create-packages/creating-a-package and make sure the required file 'MyCommonPackage' is under the folder structure before we run the nuget pack command to generate the .nupkg file.

    I removed the package references, deleted the folders from the NuGet gallery and then re-published them from the bottom-up. This time it just worked like a dream (with no changes apart from re-publishing).