Setting Up a Local NuGet Gallery and Feed

I recently experimented in setting up a local NuGet Gallery for my company to distribute some internal framework assemblies and here are some of the steps that I went through that maybe helpful for anyone who is doing the same.

Setting up the Server

  1. Download the source code from GitHub.
    [Note: You can download everything in a zip file]
  2. Extract the zip file to a folder.
  3. Open the solution in Visual Studio 2012.
  4. Add an App_Data folder to the Website project.
  5. Build the Solution.
    [Note: All the dependent NuGet packages will be downloaded and installed]
  6. Change the NuGetGallery connection string in the Website project's web.config file to your SQL Server.
    [Note: I used a SQL Server, LocalDB not working for me]
  7. Go to Tools->Library Package Manager->Package Manager Console.
    [Note: You need NuGet installed to get this]
  8. Enter and execute the command: update-package EntityFramework
  9. Shutdown and restart Visual Studio 2012.
    [Note: You must do this!]
  10. Re-open the solution.
  11. At the Package Manager Console, enter and execute the command:  update-database
    [Note: This creates the database]

If everything is done correctly, you should be able to browse to your local NuGet website now. You can then publish it to an IIS server. To ensure that your NuGet Website can run in IIS, you will need to grant the IIS_IUSRS account modify access to the App_Data folder.

Setting up the Feed

Once your NuGet Gallery is up and running on IIS, you can then provide a NuGet feed to your developers. Instruct your developer to perform the following on their Visual Studio 2012.

  1. Go to Tools->Library Package Manager->Package Manager Settings[Note: Only appears when there is an opened Project]
  2. The Options dialog opens.
  3. Expand the Package Manager->Package Sources tree.
  4. Add a new package source.
  5. Specify the Source as http://[put-your-server-name-here]/nuget/api/v2
  6. Click Update.
  7. Click OK to close the Options dialog.

The developers should be able to get your NuGet packages from their Visual Studio now.

No comments:

Post a Comment

Popular Post