One solution is to publish packages to NuGet, allowing projects to download and implement the package. Assemblies are automatically referenced (using the correct assemblies for the framework version used) and content is placed in the correct directory structure. Powershell scripts can even be used and executed on first install, update and uninstall, and developers are notified when they open a project where a package has an update available. However, if this is bespoke code it’s probably not desirable to publish the package to a public NuGet repository. This is where a private NuGet repository comes in useful, and it’s surprisingly easy to implement.
Creating the NuGet Server
Open up Visual Studio and create a new ASP.NET Empty Web Application Project. Assuming you have NuGet package manager installed, right click on the project and select Add Library Package Reference. Search for NuGet.Server and click install.
You’ll see a number of dependencies installed such as NuGet.Core, Ninject and Elmah (you’ll need to accept the Ninject agreement), and once installed you’ll see a few new folders in your project.
The packages folder is where you place the packages you’d like to make available to people who can see your NuGet Server. That’s it! Hit F5 and you’ll see a webpage with info about the NuGet repository.
Publish the project on a web server somewhere within your organisation, taking note of the URL displayed within the page (once published).
Configuring NuGet Package Manager
Now head back to Visual Studio and click Tools > Options. Scroll down to package manager and enter a name and the URL from your repository.
When adding a new library package, your new server should show up in NuGet Package Manager.
All done! I’ll be blogging in the next few days about creating your nupkg files (including the package manifect or nuspec file) to place into the packages directory to allow projects to download and implement.