Skip to main content

Hosting your own NuGet feeds

There are multiple ways to host your own NuGet feeds:

  • Using a fileshare
  • Using MyGet
  • Using the NuGet server package
  • Using the NuGet Gallery  code
Hosting your NuGet feeds using a fileshare

This is probably the easiest solution. Just create fileshare on a server somewhere and put all your packages on this share. This approach has one big disadvantage, it becomes rather slow when the number of packages grows.

Hosting your NuGet feeds on MyGet

image

MyGet, also known as ‘NuGet as a Service’ allows you to create and host your own NuGet feed. It allows you to include packages from the official NuGet feed or upload your own NuGet packages. It offers lots of nice features and best of all if you don’t need private feeds, it’s free!

Hosting your NuGet feeds using the NuGet server package

This option needs a little bit more work.

  1. Create an empty ASP.NET MVC(or WebForms) project.
  2. Download the NuGet.Server package from the official NuGet feed. This will create a simple oData feed.
  3. Deploy the application to a webserver of your choice.
  4. Add or remove packages by putting them in the Packages folder that is created for you.

Big advantage of this approach is that it introduces some caching improving the performance of the NuGet feeds.

Hosting your NuGet feeds using the NuGet Gallery

image

The last option but also the most complex one is to use the NuGet gallery, the same code that the NuGet team is using to host NuGet.org. Unfortunately you’ll have some work to get everything up and running:

  1. Download the latest source from GitHub.
  2. Navigate to the Website subdirectory and open the web.config. Inside the web.config change the following options:
    1. Modify the configuration/connectionStrings/NuGetGallery key so it points to your locally hosted SQL Server.
    2. Change the appSettings/GalleryOwnerEmail to the email address of the person who is going to administer the site.
    3. Change the appSettings/Configuration:SiteRoot to reflect the domain name you are going to use for the site.
  3. Run the Build-Solution.ps1 script using Powershell in the root directory. This will compile the website and assemble the binaries.
  4. Open up your IIS Manager
    1. Create a new application pool. The pool should use the 4.0 framework and use an integrated pipeline.
    2. Create a new website. Set the site’s physical path to point at the Website directory. Also make sure the site uses the application pool that you created in the previous step. Do not start the website yet.
  5. Open up SQL Server Management Studio
    1. Grant db_creator to the identity of the application pool you created earlier. The account needs db_creator because the first time you run the application, the Entity Framework context initializer will run. If no database exists yet then it will create the database for you. After the database is created, you can trim back the permissions to db_datareader and db_datawriter.
  6. Navigate to the NuGet gallery website. It may take a second or two for the page to appear because the database gets created during the first run.

Popular posts from this blog

DevToys–A swiss army knife for developers

As a developer there are a lot of small tasks you need to do as part of your coding, debugging and testing activities.  DevToys is an offline windows app that tries to help you with these tasks. Instead of using different websites you get a fully offline experience offering help for a large list of tasks. Many tools are available. Here is the current list: Converters JSON <> YAML Timestamp Number Base Cron Parser Encoders / Decoders HTML URL Base64 Text & Image GZip JWT Decoder Formatters JSON SQL XML Generators Hash (MD5, SHA1, SHA256, SHA512) UUID 1 and 4 Lorem Ipsum Checksum Text Escape / Unescape Inspector & Case Converter Regex Tester Text Comparer XML Validator Markdown Preview Graphic Color B

Help! I accidently enabled HSTS–on localhost

I ran into an issue after accidently enabling HSTS for a website on localhost. This was not an issue for the original website that was running in IIS and had a certificate configured. But when I tried to run an Angular app a little bit later on http://localhost:4200 the browser redirected me immediately to https://localhost . Whoops! That was not what I wanted in this case. To fix it, you need to go the network settings of your browser, there are available at: chrome://net-internals/#hsts edge://net-internals/#hsts brave://net-internals/#hsts Enter ‘localhost’ in the domain textbox under the Delete domain security policies section and hit Delete . That should do the trick…

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.