Publish NuGet packages

If you are new to Buddy, check out our quickstart guides that will tell you how to create build, test and deploy your type of application.

Buddy turns deployments into a breeze, allowing you to automatically build and push packages to the NuGet Gallery: Pipeline examplePipeline example

NuGet Configuration

To configure NuGet you first need an account on To push packages to the gallery, you need an API key that can be found on your NuGet account page in the API Keys section (if you don't have any API key you can generate one there).

With the NuGet account and the API key created, you can now proceed to your project. First, add the NugetDemo.nuspec file to your project directory:

Filesystem windowFilesystem window

In this file, you have to specify the following:

  • <id> – unique id of the package. It will also server as the package name displayed in the Package Manager Console and will be used in the Install-Package command
  • <version> – package version in a 1.2.3 format
  • <authors> – list of authors separated with commas
  • <description> – package description that will be displayed in 'Add Package Dialog' in the Package Manager console and after using the Git-Package command

NuGet configurationNuGet configuration

Pipeline configuration

With everything set up, you can now add a new pipeline:

Adding a new pipelineAdding a new pipeline

Once you have set up your new pipeline, it's time to add the action. Select the Custom Build action:

Custom Build actionCustom Build action

Switch to the Environment tab and select the library/mono Docker image in the latest version:

Pull latest version od the docker imagePull latest version od the docker image

The Docker image is set up, so you can now enter the build commands. Go back to the Run tab and enter the following commands in the SH console:

xbuild /p:Configuration=Release /p:TargetFrameworkVersion="v4.5" NugetDemo/NugetDemo.csproj
nuget setApiKey 777777777-6666665-5555555-4444444-33333333333333
nuget push BuddyNugetDemo.$BUDDY_EXECUTION_COMMENT.nupkg

In the second and last line we have used $BUDDY_EXECUTION_COMMENT – this means that every time you execute a pipeline you will be able to enter a comment. This also means that you will have to make sure that whenever you execute it, the package version is correct or it will fail to push the package to the NutGallery.

If you want to automate package version numbering, you can follow our tutorial on this matter.