Pushing to NuGet

Part of my recent PushbulletSharp updates was getting my software to NuGet. There’s a couple of tutorials out there that will guide you through it, and I’m going to add to that list with my experience of creating the PushbulletSharp NuGet package.

Out of all of the tutorials out there, the one that helped me along the most was called 5 simple steps to publishing a NuGet package by Damien Guard. I recommend reading through this guide as it will help you get your package created and published to NuGet. Some of it is out of date now, and I’ll cover that, but for the most part it’s great.

Here’s what I did to get PushbulletSharp on NuGet:

Step 1:
Download the nuget.exe from NuGet.org’s Installing NuGet page. For my project I created a folder called ‘nuget’ and added it to the .gitignore file because I didn’t want to push it to GitHub. The entry is just ‘nuget/’. I placed the nuget.exe file inside that directory.

The entries to pay attention to are the two file child nodes under . Because the nuget.exe is in a folder called nuget at the root of my project, I only had to go back one directory and then navigate to PushbulletSharp\bin\Release\. From there I’m getting all .dll files and .pdb files. Since I’m using .NET 4.5, I set that as my target with ‘target=”lib\net45″‘.

Step 4:
Creating the .nupkg file. With a PowerShell window type in:

nuget pack Package.nuspec

Step 5:
One of the coolest things about nuget is being able to add your own local or shared repository. This can be extremely awesome if you’re in an organization that has multiple teams needing to use internal libraries. You can setup a shared drive and configure Visual Studio to point to the shared drive as a corporate nuget repo.

To do this locally, create a test folder. I created one at ‘D:\_workarea\NugetTestRepo’.

Next I published my package to it with ‘nuget push Package.nuspec -source D:\_workarea\NugetTestRepo’.

Next in Visual Studio go to ‘Tools > NuGet Package Manager > Package Manager Settings > Package Sources’. Click the Plus sign near the top right to add your local repo. I named mine ‘Local Testing’ and the directory is ‘D:\_workarea\NugetTestRepo’.

Doing this will allow you to create a test project where you can add your nuget package and test it locally before pushing it live.