How to publish a open source nuget package

I have a piece of code that enables ELMAH SQlErrorLog to pull the connection string from the app settings. I needed that in order to make use of AppHarbor’s configuration variables.

In this article, I am going to document the process I went through to open source the code, and package it in a nuget package.

Create a new repository on GitHub


Make sure to tick the “Initialize this repository with a README”.

If your project is a .NET project, you can choose the VisualStudio .gitignore configuration.

Once your repository is created grab the url:


And execute “git clone <URL>”.

Move your project files in the new folder:



Prepare project to be published as a nuget package

First I needed to download the nuget.exe command line tool.

Then I run “nuget spec” in the folder where my .csproj file is. This generates a standard .nuspec file.

I included that file to the project and replaced the values:



Generating and publishing the package

I called “nuget pack WiseLabs.AppSettings.csproj” to generate the .nupkg file.

I called “nuget setApiKey API-Key”. (You can find your API key in your account).

“nuget push WiseLabs.AppSettings.0.1.nupkg”

That’s it, your code is available as a package and can be installed in a project using “Install-Package WiseLabs.AppSettings”.

Pushing the code to github

At the root for the repository folder:

git add –A

git commit –am “First commit”

git push origin master