Skip to content

Hosting the NuGet Gallery Locally in IIS

Robert Muehsig edited this page May 23, 2016 · 32 revisions
  1. Ensure IIS is installed with the recommended configuration:
  2. Ensure IIS URL Rewrite Engine is Installed (alternatively please remove that section from the web.config since it is only used for
  3. Ensure that the .NET Framework 4.5 is installed:
  4. If you don't have Visual Studio 2012 installed, you will need to install the .NET Framework 4.5 Software Development Kit in order to get the reference assemblies: (uncheck all other components and install only the .NET Framework 4.5 SDK if you are on Windows 7 or Windows Server 2008/R2)
  5. Get the source: git clone
  6. Create a new site in IIS, on port 80 (yes, it must be port 80)
  7. Ensure the new site's app pool is using .NET 4
  8. Ensure that app pool's identity has permission to the database specified in web.config (if using integrated security, otherwise just make sure to set the connection string properly).
  9. Open Visual Studio 2012/2013 and open Package Manager Console
  10. Edit the settings in the Web.config to match your setup, specifically the database connection string and the email settings.
  11. Ensure that the default project is NuGetGallery and go to the Package Manager Console
  12. Run the command Update-Database -ConfigurationTypeName MigrationsConfiguration
  13. Edit the dbo.GallerySettings table in Microsoft SQL Server Management Studio so that the SMTP settings, gallery owner name, and gallery owner email are set up appropriately. You may also want users to confirm their email addresses.
  14. Select the Publish command from NuGetGallery and select Custom, enter the details of the server/site you created and publish it OR you can build the site and take the compiled bits and set them up yourself in IIS.
  15. Test the site by going to the home page
  16. Test the API by nuget push <package> -source http://localhost/api/v2/package -apikey <apikey>

If everything works fine, you can register a user and make it an Admin by adding a record to the UserRoles table.

Admin users can view the gallery's error log at http://localhost/elmah.axd

Something went wrong with that request. Please try again.