Setup Own NuGet Gallery in Minutes

Setup Own NuGet Gallery In MinutesToday I setup a yet another flavor of a NuGet feed, TeamCity NuGet Feed and NuGet Gallery. The TeamCity NuGet Feed was effortless and completed in less than five minutes once I upgraded to 7.0 ( Whats new in TeamCity 7.0 ). NuGet Gallery setup is simple, granted not as simple as TeamCity NuGet Server setup but easy enough to be up in less than 10 minutes.

In addition, discovered a few new offerings related to NuGet Community today. provides the ability to add packages to a personalized feed or follow releases until a stable package is released. The site also offers a Chrome browser extension to follow NuGet packages as RSS feeds and Visual Studio Extension to export referenced NuGet packages to from the VS IDE. TFS nugetter is an extension for TFS 2010 build process performing all of the necessary versioning, packaging, and deployment functions in a customizable and completely repeatable manner. An update to the Community TFS Build Extensions was released this past January.

Community TFS Build Extensions is a collection of around 100 activities that can provide many commonly requested functions including running CodeMetrics and NUnit tests, creating a Zip archive, wrapping RoboCopy for deployment, updating AssemblyInfo files, running StyleCop, merging assemblies with ILMerge etc etc.

Listed below are the personalization options for NuGet that I’m aware of at the time of this writing. The post outlines TeamCity and NuGet Gallery options.

Personalized NuGet Feed Options:

  1. Network Share
  2. Own Local Cache
  3. NuGet Server
  4. NuGet Gallery
  5. NuGet Orchard Gallery
  6. TeamCity
  8. MyGet

Go Pro NuGet!

Time to knockout TeamCity 7.0 NuGet Feed Server setup in a few minutes ( this does not include upgrade time ) then tackle the slightly more complicated NuGet Gallery setup.

TeamCity NuGet Support

TeamCity 7.0 out of the box supports NuGet integration.

  • installing and updating NuGet packages on agents
  • creating NuGet packages
  • publishing package to a given NuGet feed
  • act as a NuGet feed server
  • trigger builds on changes in a specified NuGet package

TeamCity NuGet Setup

Installation and upgrade of TeamCity is out of scope. Please leverage the provide links to learn more about TeamCity 7.0 instillation or upgrade path. Once TeamCity 7.0 us up configuration of the NuGet Feed Server takes less than 5 minutes.


  1. TeamCity 7.0 Installation and Upgrade

TeamCity NuGet Feed Server Setup

  1. Login with Adminstrator Role
  2. Click on Adminstration link in upper right corner
  3. Click on Integrations -> NuGet Settings link on left menu
  4. Click on NuGet Server Enable button to enable the NuGet Feed Server
  5. Click on the Authentication Feed URL to view the feed in a browser, notice you must authenticate.
  6. To allow public access the Guest User Log-on must be enabled.
  7. Added the TeamCity Feed to your Package Manager package sources Tools -> Library Package Manager -> Package Manager Settings
  8. Click Package Sources under Package Manager on the left Options section
  9. Add a name NuGet TeamCity Feed
  10. Paste in the public URL for TeamCity NuGet Feed Server
  11. Click Add button

TeamCity NuGet Feed Server Setup

TeamCity NuGet Command Line Setup

TeamCity Command Line Setup

  1. Login with Adminstrator Role
  2. Click on Adminstration link in upper right corner
  3. Click on Integrations -> NuGet Settings link on left menu
  4. Click on NuGet Commandline tab
  5. Click on Download NuGet to install the latest version of NuGet command line bootstrapper
  6. Notice TeamCity permits multiple versions of NuGet Command Line to be installed

NuGet Gallery Setup

Before we jump into the setup. If you have not already seen Enterprise NuGet talk Scott Hanselman at Tech Ed last year it is a MUST. There are a few post regarding NuGet Gallery setup BUT the post most helpful to me was by Michael Cernaski How to Set Up a Local NuGet Gallery. That said, I will make reference to Michael’s post and add additional details or further explanation related to my setup experience. Please read Michaels post before continuing BUT do not start the process until reviewing the steps below as I’ve changed the order and altered some content.

First, I will reiterate, at the time of this writing the NuGet documentation on setting up a local NuGet Gallery is outdated. Outlined below are the steps, in order, with altered content that supplement the steps in Michael’s blog post. I recommend following the steps below in order and refer to Michaels blog for additional details on certain brief steps.

  1. Visual Studio 2010 or greater
  2. PowerShell 2.0.
  3. NuGet VS Extension NuGet Command Line
  4. Windows Azure SDK – Both PowerShell and the Windows Azure SDK can also be installed via the Microsoft Web Platform Installer.
  5. Download latest source from GitHub
  6. Open SQL Server Management Studio, create a new database user for NuGet Gallery database ( db does not exist yet leave set to master) usr_nuget. For now grant the user db_creator to permit EF to setup db on first run.
  7. Update web.config settings and database connection ( using user name and password ) in Website directory
  8. Update /WebSite/Content/Images/nugetlogo.png to be unique to you
  9. Run Build-Solution.ps1 using PowerShell ( you must have unrestricted execution policy set )
  10. Open IIS Manager, create new application pool for .NET 4.0 with integrated pipeline
  11. Create a new WebSite, called NuGetMyCustomNameGallery and set to physical path to WebSite dir.
  12. If Web Site is not started, start it and browse to site and register a new user for yourself
  13. Open SQL Server Management Studio, remove the db_create permission for the usr_nuget, save. Now set usr_nuget to NuGetGallery database and only grant db_datareader and db_datawriter permission.
  14. Update your user account to be administrator by running the following code against the database.
  15. Navigate to your site dbadmin view – http://localhost:8111/dbadmin
  16. Click on GallerySettings to set SMTP settings, GalleryOwnerName and GalleryOwnerEmail. You can manage the rest of the site here too.
STEP 7 Web.Config Connection String Section
    <add name="NuGetGallery" connectionString="Server=MyMachineName\MYSQLSERVERNAME;Initial Catalog=NuGetGallery;User ID=usr_nuget;Password=MyNuGetStrongPwd1;" providerName="System.Data.SqlClient" />
STEP 14 SQL Code
INSERT INTO [dbo].[UserRoles] ([UserKey], [RoleKey])
  VALUES ( (SELECT TOP 1 [Key] FROM [dbo].[Users]), 1)