By: Nash Mbaya
For the Daden U Day I decided to look into creating a private NuGet feed for Daden.
NuGet is the package manager for the Microsoft development platform. Our main development tool here at Daden is Microsoft visual studio which is part of this platform. As a result we use NuGet and its public feed in our projects as way of managing external code.
So what about internal code you ask. How is that managed? The short answer and simple answer is that it was not before I wrote this blog post. If there was utility a class or a script written by any of the developers here and another developer wanted to use the same code they would have to firstly know of codes existence. Then secondly they would have to hunt for a latest version of that script, class or dll which could be in any number of projects.
So the aim of creating Daden’s own private NuGet feed was to eliminate a some of the issues caused by this by:
1.Creating a central repository for Daden’s library files.
2.Reducing the fragmentation of said libraries files having a NuGet feed which would provide the latest version of any of our library files.
3.Improving awareness of the different libraries and scripts that are available to Daden’s internal development team
4.Automatically updating library files which are in use.
There are three main ways of creating your own NuGet feed. You can either have a local feed which is a simple folder with packages on your machine or a shared network drive. You can buy a hosted solutions in the cloud or you can also host a remote (or internal) feed on a server that runs IIS. I chose the latter because I didn't want to rely on the windows file system but instead utilise the IIS server that Daden already has which is used to serve intranet web pages.
Setting up the local feed is easy and straightforward.
Step 1: Create a new Empty Web Application in Visual Studio
Step 2: Install the NuGet.Server Package using the NuGet package manager in Visual Studio
Step 3 (Optional): Configure the Packages folder
The default Packages folder is a folder within the web application hierarchy in the solution view.
To change the folder to one of your choice open the web.config file and change the value of the ‘packagePath’
Step 4: The final step is to publish the web application.
So the purpose of NuGet is to manage packages. But what are packages? what do they look like? and how can I make one?
Packages can be formed of a ‘lib’ folder which should only contain .dll files. A ‘content’ folder which can hold any kind of script or file you want to be part of the project. .NET assembly files inside the ‘lib’ file will added as references to the project. Files located in the ‘content’ folder will be added to the root folder of the project. Folders can also be placed in the ‘content’ folder.
At the begin of the U Day I initial attempted to create NuGet packages using the command line. The commands were simple and straightforward but unfortunately the packages I was creating were not valid, so decided to use the Nuget Package Explorer. NuGet Package Explorer is a version of nuget.exe command line application with a user interface. Though the nuget.exe command line application is useful if you plan to incorporate package creation and publishing into build process I would recommend using NuGet Package Explorer. When you launch the application you are presented with two panels. In the left panel you enter metadata about the package. In the right panel you build up the structure of the package by creating the previously mentioned ‘lib’ folder or ‘content’ folder. You can then add your files to the package. Finally you can publish the package and of course, save it!
Apart from problems I had with the nuget command line application, which were probably through my lack of understanding, I would highly recommend NuGet. The GUI tool was a breeze to use. Now Daden is running its own private NuGet feed enabling us to easily manage and reuse library files across different applications.