Hosting the NuGet Gallery Locally in IIS

Scott Bommarito edited this page Jan 9, 2017 · 33 revisions

Note: These instructions are fairly out of date. There is an issue in our backlog to modernize them. The instructions located in our should be sufficient to build and run the gallery locally.

  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 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 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 Web.Config 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

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.