Search code examples
.netvisual-studionugetnuget-server

NuGet.Server Dependency Reference


I am trying to get a self hosted NuGet server working, the idea is to keep small libraries to use in multiple projects.

I am using NuGet.Server (https://www.nuget.org/packages/NuGet.Server/ https://docs.nuget.org/create/hosting-your-own-nuget-feeds) to do this, and it seems to be working.

The problem I have, is when I then try and add the package to a project (after adding the URL to Package Source in Visual Studio), it tries to add the package, but it fails on dependencies (e.g. System.Linq). It tries getting the dependency from my hosted source, and not from nuget.org.

Is there a way to get it to use nuget.org, or at least look at other sources for dependencies?

I have tried setting Package Source to "All", and I still get the same problem. I have also tried installing through the Package Management Console.


Solution

  • You need to install the dependencies when you create your packages. I do with following steps and it successful install the package and its dependencies on my project from my own NuGet Server.

    1. Create a project.
    2. Install the dependencies packages on your project through Package Manager.
    3. Create spec file for your package with command “nuget spec” through nuget.exe.
    4. Pack your project with command “nuget pack YourProject.csproj”.
    5. Upload this package to your NuGet Server and then you can install it through the Package Manager from your added package source.

    The detailed steps about pack the packages with nuget.exe, you could refer to: https://docs.nuget.org/create/creating-and-publishing-a-package

    And you also can use NuGet Package Explorer to assign the dependencies more easily. http://www.marcusoft.net/2011/09/creating-local-nuget-repository-with.html