-
Notifications
You must be signed in to change notification settings - Fork 654
Hosting the NuGet Gallery Locally in IIS
DavidS edited this page Mar 22, 2013
·
38 revisions
- Ensure IIS is installed with the recommended configuration: http://www.microsoft.com/web/gallery/install.aspx?appid=iis7
- Ensure IIS URL Rewrite Engine is Installed (alternatively please remove that section from the web.config since it is only used for nuget.org).
- Ensure that the .NET Framework 4.5 is installed: http://www.microsoft.com/en-us/download/details.aspx?id=30653
- Get the source:
git clone [email protected]:NuGet/NuGetGallery.git
- If you are not going to use SSL, please edit NuGetGallery/Website/Controllers/AuthenticationController.cs: remove the
[RequireRemoteHttps]
attribute from two methods surrounding Logon. - 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 ReadAppSettings<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" />
- Build the solution:
build.bat
from the command line (it builds to _PackagedWebsite) - Create a new site in IIS, mapped to <nuget-source>\Website, on port 80 (yes, it must be port 80)
- Ensure the new site's app pool is using .NET 4
- Edit the settings in the Web.config to match your setup, specifically the database connection string and the email settings.
- 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).
- Test the site by going to the home page
- 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