Search code examples
nugetnuget-server

How do I host my own nuget v3 feed?


My organization has several nuget v2 feeds (.net app consuming nuget.server) for our internally developed packages and to re-host third party packages (since our build machines do not have internet access and we audit what packages developers consume within our product and would like the builds to fail if we don't have a package).

Whenever I add any packages that require nuget client 3.0+ to my nuget servers, the nuget server crashes because it cannot read metadata from those packages. How do i host my own nuget v3 server / upgrade my existing nuget servers to be v3 compatible?


Solution

  • I wrote a nuget server aspnetcore middleware recently.

    Of cource the implementation is so foolish, ugly etc... link

    You can set up it in the Startup.cs

    public void ConfigureServices( IServiceCollection services )
    {
        ...
        services.AddNugetServer(opt=>
        {
            opt.ApiKey = "This is a string used for adds or deletes your package(s)";
            opt.PackageDirectory = "/path/to/your/packages"; //default is current path + "/packages"
        });
        ...
    }
    
    public void Configure( IApplicationBuilder app, IHostingEnvironment env )
    {
        ...
        app.UseNugetServer();
    }
    

    And visit http(s)://your-server-address[:port]/v3/index.json

    Publishing:

    dotnet nuget push -s http(s)://your-server-address[:port]/v3/package package.nupkg