NuGet.Server is a package provided by the .NET Foundation that creates an ASP.NET application that can host a package feed on any server that runs IIS. Simply said, NuGet.Server makes a folder on the server available through HTTP(S) (specifically OData). It's easy to set up and is best for simple scenarios.
- Create an empty ASP.NET Web application in Visual Studio and add the NuGet.Server package to it.
- Configure the
Packagesfolder in the application and add packages.
- Deploy the application to a suitable server.
The following sections walk through this process in detail, using C#.
Create and deploy an ASP.NET Web application with NuGet.Server
In Visual Studio, select File > New > Project, set the target framework for .NET Framework 4.6 (see below), search for "ASP.NET", and select the ASP.NET Web Application (.NET Framework) template for C#.
Give the application a suitable name other than NuGet.Server, select OK, and in the next dialog select the Empty template and select OK.
Right-click the project, select Manage NuGet Packages, and in the Package Manager UI search and install the latest version of the NuGet.Server package if you're targeting .NET Framework 4.6. (You can also install it from the Package Manager Console with
If your web application targets .NET Framework 4.5.2, you must install NuGet Server 2.10.3 instead.
Installing NuGet.Server converts the empty Web application into a package source. It creates a
Packagesfolder in the application and overwrites
web.configto include additional settings (see the comments in that file for details).
To make packages available in the feed when you publish the application to a server, add their
.nupkgfiles to the
Packagesfolder in Visual Studio, then set their Build Action to Content and Copy to Output Directory to Copy always:
Run the site locally in Visual Studio (without debugging, that is Ctrl+F5). The home page provides the package feed URLs:
Click on here in the area outlined above to see the OData feed of packages.
The first time you run the application, NuGet.Server restructures the
Packagesfolder to contain a folder for each package. This matches the local storage layout introduced with NuGet 3.3 to improve performance. When adding more packages, continue to follow this structure.
Once you've tested your local deployment, deploy the application to any other internal or external site as needed.
- Once deployed to
http://<domain>, the URL that you use for the package source will be
Configuring the Packages folder
NuGet.Server 1.5 and later, you can more specifically configure the package folder using the
appSetting/packagesPath value in
<appSettings> <!-- Set the value here to specify your custom packages folder. --> <add key="packagesPath" value="C:\MyPackages" /> </appSettings>
packagesPath can be an absolute or virtual path.
packagesPath is omitted or left blank, the packages folder is the default
Adding packages to the feed externally
Once a NuGet.Server site is running, you can add or delete packages using nuget.exe provided that you set an API key value in
After installing the NuGet.Server package,
web.config contains an empty
<appSettings> <add key="apiKey" value="" /> </appSettings>
apiKey is omitted or blank, pushing packages to the feed is disabled.
To enable this capability, set the
apiKey to a value (ideally a strong password) and add a key called
appSettings/requireApiKey with the value of
<appSettings> <!-- Sets whether an API Key is required to push/delete packages --> <add key="requireApiKey" value="true" /> <!-- Set a shared password (for all users) to push/delete packages --> <add key="apiKey" value="" /> </appSettings>
If your server is already secured or you do not otherwise require an API key (for example, when using a private server on a local team network), you can set
false. All users with access to the server can then push or delete packages.