Enable javascript in your browser for better experience. Need to know to enable it? Go here.
Blogs Banner

Updated: How To Use NuGet With Thoughtworks Go


Developers using the Microsoft technology stack have adopted NuGet as a primary dependency manager. NuGet provides a clean way to acquire interesting reusable components from a reliable public source, stay up to date with new versions of the components (or not), and even use your own NuGet private NuGet repository internally.
One of Go’s strengths is its extensibility. Almost anything that can be run from a command line can be integrated into a Go pipeline and value stream.

This blog shows you how to use NuGet with Go to:

  • Build and publish NuGet packages to public and internal repositories. You can choose to publish manually or automatically as part of a full-up continuous delivery value stream. Mingle.NET is an example of a NuGet package that is built, tested and published this way.
  • Acquire NuGet packages on the fly at build time from public and private repositories. You can choose whether to get the most recent versions of such packages or not.

Publishing Packages

You publish NuGet packages from Go using the NuGet command line utility. This is true for both public and private repositories. To use the NuGet command line you need to have its software on each machine running Go agent(s). Here you have choices:
Note: “Allow NuGet to download missing packages during build” fetches package versions as listed in packages.config in your project. It does not download the latest available versions of packages. We’ll deal with this issue under Acquiring Packages below.
Assuming you have defined your package(s) with appropriate .nuspec files, you can publish from Go using a command line like this:

nuget push MingleNET.1.5.%GO_PIPELINE_COUNTER%.nupkg %NUGETAPIKEY%

%GO_PIPELINE_COUNTER% is the Go environment variable with a monotonically increasing value each time the pipeline runs. I use this to set a newer version number each time the package is published.
%NUGETAPIKEY% is a secure environment variable defined in the pipeline specification that holds the secret API key.
Done. We’re now publishing a NuGet package to either a private internal repository or a public repository.

Acquiring Packages

Packages are easily acquired from NuGet using the command line utility’s install command. If you want to pin your NuGet dependency to a particular version do this:

nuget install your-nuget-component -o packages -Source http://YourNuGet/NuGet

If you want to build with the latest version of a NuGet dependency do this:

nuget install your-nuget-component -o packages -Source http://YourNuGet/NuGet -ExcludeVersion


How do you do Continuous Delivery With IIS, NuGet, Chef and TFS?

Register for the webinar now

Disclaimer: The statements and opinions expressed in this article are those of the author(s) and do not necessarily reflect the positions of Thoughtworks.

Keep up to date with our latest insights