nuget-logo2_thumb.pngIf you are .NET developer you no doubt heard about NuGet – this little package manager rapidly becoming a big deal in .NET open source community. There is a lot to like about it, and if you want to learn more go subscribe to Phil, Scott Hanselman or Scott Guthrie blogs to stay on top. To me interesting question is how NuGet can help me with daily development, for example, how can I apply it to build things for BlogEngine? Lets check this out.

Business as usual

vsfiles_thumb.pngA while ago I did a widget that shows visitor info in the sidebar. It got out of date, and I decided to update it for BE 2.0. I downloaded old source code from my own blog, it is a ZIP file that I had to extract locally. Inside I found “widgets” folder, dragged it over “widgets” folder in BE 2.0 project and content of widgets got merged. Simple enough, right? And this is how it works in BlogEngine world, you download/unzip/merge files into your blog’s directory. To upgrade widget I added couple references to namespaces that changed in 2.0 and call it done. Ok, how do I package it for distribution? Easy – create folder called “widgets”, inside it create folder called “Feedjit” and add updated source files there. Then right-click “widgets” folder –> send to –> compressed (zipped) and I’m done. Resulting ZIP file is what other people will download, unzip and merge to their blogs to be able to use Feedjit. That not hard but obviously screams for automation. And we could build unzip/merge process into BlogEngine pretty easily, but there is so much better way.

Lets get NuGety

What I want is to package my widget into .nupkg format used by NuGet. Lets do it step by step.

  1. Create working directory, say c:\packages and add “Feedjit” folder to it. Inside it create folder “content” – you can think of it as your blog root directory.

  2. Copy folder structure created to build standard ZIP file and move it to that “content” folder. You should get: c:\packages\Feedjit\content\widgets\Feedjit and 4 source files inside it.

  3. Download NuGet.exe and move it to c:\packages.

  4. Now create spec file for the widget, it looks like this:

    Feedjit rtur Feedjit lets you see friends and visitors as they arrive on your blog or website. en-US

and save it as Feedjit.nuspec in the C:\packages\Feedjit (at same level as “content”).

  1. Open command prompt, change to c:\packages and run this line:

    nuget pack feedjit\feedjit.nuspec

The result should look something like this:


Congratulation, we created our first NuGet package! But… how do we know it works? Lets install it!

The Visual Studio story

In my Visual Studio project, I delete “Feedjit” folder with all source files in it. That effectively uninstalls widget from solution. Here is how to install it from NuGet package we created:

  1. Right click BlogEngine.NET project and select “Add Library Package Reference”. In the dialog box, click “Settings” in the lower left corner.

  2. To add our “c:\packages” as local repository, fill in name and source and hit “ok”


From now on, you should be able to select that local feed and install any NuGet package that you have inside c:\packages folder. Here is what my local repository looks like:


Click “Install”, and Feedjit will be added to solution, just like that. We got all power of NuGet here, for example you can just as easily uninstall package:

uninstall_thumb.pngUpdate and versioning all provided by NuGet, so if you happen to have multiple versions of your widget, extension or theme – you’ll just package it with new version number and you done. Pretty cool stuff. What could be more cool?

BlogEngine.NET gallery

Having local package repository is great. You could even submit your package to official NuGet feed and let people know about that wonderful extension you created, so they can install it from Visual Studio. But can we haz app store plz?

Yes we can! Please meet Ok, just to be clear – see that “beta” in the logo? It is wrong. It should really be “alpha” so if you crash site it is all your fault. But it should let you to register and upload your packages. Don’t’ tell anyone, just try it yourself and let us know what works and what doesn’t, we are very interested in your feedback. The process is very much identical to Orchard Gallery, except we don’t require email validation at this point so it is simpler a little.

Don’t get too excited just yet, we still missing a link when blogger can go to admin and click “install” button. Right now, it is just what it is – online repository to store and promote your packages. To install it, someone would have to download .nupkg file and then either rename/unzip/merge manually or add gallery feed to Visual Studio sources and get it from there. But that “Install” button is very high on to-do list.