Well, we started running into an issue with Nuget.Server and it was time to migrate to NugetGallery. Mainly, it wouldn't clean itself up (after a few days, there were 10's of gigs of temp files in c:\windows\temp\nuget), and now that we have a couple thousand packages it started really slowing down. It was just time. So here goes what I did to make this work.

Initial Steps:

  1. Clone NugetGallery from github
  2. Configure NugetGallery settings (database, etc)
  3. Modify the web.config in the NugetGallery project
    • Change appSettings/Gallery.SiteRoot to whatever it should be, I could only see this in the email verification
    • If you want to actually send the emails, set appSettings/Gallery.SmptUri to smtp://<user:pass>@server:<port>. If you use just a server name (like a lot of smtp servers) just use smtp://server. If you don't set it, they will be stored in the App_Data folder.
    • Empty the appSettings/Gallery.ServiceDiscoverUri, by default it is set to "n", you will receive an exception stating something about relative uri's are not valid if you dont either empty this or set it to a valid url.
    • Update appSettings/Gallery.Brand to say something like Company - Nuget. This makes it easy to see that it's your local nuget as it updates the <title></title> tag in the pages.
    • Set the appSettings/Gallery.GalleryOwner to be the correct from email address in the format of email@domain.tld &lt;Display Name&gt;. The &lt; &gt; must be the escaped <> in order for it to work.
    • Update the database connection string. connectionStrings/Gallery.SqlServer- if you want sql express you don''t want to change it. But I''m not, so I modified it to point to a local server. Be sure to create the database you want to use before hand and set the Initial Catalog.
    • That''s it.

Problem areas:

  • Issue: Database Generation and errors saying it couldn't find EntityFramework 5.0.0 library as well as saying method not found or some such non-sense.

    • I have VS2015 installed on my dev system, I don't want VS2013 and I don't want to install it
    • The Fix (install EntityFramework5 into the GAC):
      1. Open VS2015, don't open any projects.
      2. Open the package manager console
      3. Open the NugetGallery solution.
      4. Build the solution (this will download all packages)
      5. Open up a developer prompt
      6. "cd" into the Solution folder cd into Packages\EntityFramework5.0.0\lib\net45
      7. Run gacutil /i EntityFramework.dll
      8. Back in the package manager, in VS2015,
      9. Select the nugetgaller as the "project"
      10. run update-database
  • Issue: Server only has .net 4.5.1 (annoying, but I wasn't allowed to update it to 4.5.2)

    • The projects downgrade nicely to 4.5.2, except for one spot where it actually uses a method introduced in 4.5.2.
    • You will also need to go through the packages.config files in each of the projects and replace the 452 with 451
      src/NuGetGallery/Controllers/ApiController.cs needs to have the line where it calls QueueBackgroundWorkItem modified. I commented that line and just called the PostDownloadStatistics directly, passing a new CancellationToken(). Problem solved
      -                    HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => PostDownloadStatistics(id, version, userHostAddress, userAgent, operation, dependentPackage, projectGuids, cancella
      +                    //HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => PostDownloadStatistics(id, version, userHostAddress, userAgent, operation, dependentPackage, projectGuids, cancel
      +                    await PostDownloadStatistics(id, version, userHostAddress, userAgent, operation, dependentPackage, projectGuids, new CancellationToken());
      
  • Issue: Lucene indexes needed to be refreshed on every package upload at the time of upload. Since we don't upload very often, the performance impact was minimal.

    1. Add IndexingService.UpdateIndex(true); to the methods in in src/NuGetGallery/Controllers/ApiController.cs that update and upload the packages. This code goes right below the IndexingService.UpdatePackage(package) lines.
  • Issue: Not an admin user

    1. When registering the first user, you're not an admin user. The fix was to add the user/role to the UserRoles table. By default you will probably want to add a UserKey=1 and RoleKey=1 to the table. You get the keys from the Users and Roles tables.
    2. In order to make additional users admin users, it looked like it was a manual process. Though this was possible through the admin interface when you logged in as an admin.
  • Issue: Development message at the top of the page. "This is a development environment. No data will be preserved." and other customization

    1. The development message is in: src\NugetGallery\App_Data\Files\Content\Alert.md
    2. Other page content is located in the other files in that folder.