Skip to content

Hosting the NuGet Gallery Locally in IIS

benerdin edited this page May 30, 2012 · 38 revisions
  1. Ensure IIS is installed with the recommended configuration: http://www.microsoft.com/web/gallery/install.aspx?appid=iis7
  2. Ensure IIS URL Rewrite Engine is Installed (alternatively please remove that section from the web.config since it is only used for nuget.org).
  3. Get the source: git clone [email protected]:NuGet/NuGetGallery.git
  4. If you are not going to use SSL, please edit NuGetGallery/Website/Controllers/AuthenticationController.cs: remove the [RequireRemoteHttps] attribute from two methods surrounding Logon.
  5. If your SMTP server does not use SSL, you need to edit EnableSsl and set it to false in NuGetGallery/Website/App_Start/ContainerBinding.cs around line 102:
	 var mailSenderConfiguration = new MailSenderConfiguration()
		{
			DeliveryMethod = SmtpDeliveryMethod.Network,
			Host = settings.SmtpHost,
			Port = settings.SmtpPort,
			EnableSsl = true
		};
  • Alternatively you can make it configurable by doing the following:
    • NuGetGallery/Website/App_Start/IConfiguration.cs add:
          bool SmtpEnableSsl { get; }
 * NuGetGallery/Website/App_Start/Configuration.cs add:  
        public bool SmtpEnableSsl
        {
            get
            {
                return ReadConfiguration<bool>(
                 "SmtpEnableSsl",
                 (value) => bool.Parse(value ?? bool.TrueString));
            }
        }
 * NuGetGallery/Website/App_Start/ContainerBindings.cs  around line 102 change `EnableSsl = true` to:  
             EnableSsl = configuration.SmtpEnableSsl,
 * In the Web.config file, add this to appSettings:  
   <add key="SmtpEnableSsl" value="false" />
  1. Build the solution: build.bat from the command line (it builds to _PackagedWebsite)
  2. Create a new site in IIS, mapped to <nuget-source>\Website, on port 80 (yes, it must be port 80)
  3. Ensure the new site's app pool is using .NET 4
  4. 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).
  5. Test the site by going to the home page
  6. Once the site creates and seeds the database structure, you will likely want to update the SMTP information. Edit the following and use it to update:
  UPDATE [dbo].[GallerySettings]
  SET 
      [SmtpPort] = ''
      ,[SmtpUsername] = ''
      ,[SmtpHost] = ''
      ,[SmtpPassword] = ''
      ,[UseSmtp] = 1
      ,[GalleryOwnerEmail] = '[email protected]'
  1. Test the API by nuget push <package> -source http://localhost -apikey <apikey>
Clone this wiki locally