Posts from  November 2012


My Automated NuGet Workflow

When we develop libraries (whether internal or public), it helps to have a rapid ability to make changes and test them in a consuming application.


  • Setup the library with automatic versioning and a nuspec
    • Setup library assembly version to auto increment build and revision
      • AssemblyInfo –> [assembly: AssemblyVersion("1.0.*")]
        • This autoincrements build and revision based on time of build
      • Major & Minor
        • Major should be changed when you have breaking changes
        • Minor should be changed once you have a solid new release
        • During development I don’t increment these
    • Create a nuspec, version this with the code
      • nuspec - set version to <version>$version$</version>
      • This uses the assembly’s version, which is auto-incrementing Smile
  • Make changes to code
  • Run automated build (ruby/rake)
    • run “rake nuget”
    • nuget task builds nuget package and copies it to a local nuget feed
      • I use an environment variable to point at this so I can change it on a machine level!
      • The nuget command below assumes a nuspec is checked in called Library.nuspec next to the csproj file
    • $projectSolution = 'src\\Library.sln'
      $nugetFeedPath = ENV["NuGetDevFeed"]
      msbuild :build => [:clean] do |msb| :configuration => :Release
        msb.targets :Build
        msb.solution = $projectSolution
      task :nuget => [:build] do
        sh "nuget pack src\\Library\\Library.csproj /OutputDirectory " + $nugetFeedPath
  • Setup the local nuget feed as a nuget package source (this is only required once per machine)
  • Go to the consuming project
  • Update the package
    • Update-Package Library
    • or Install-Package
  • TLDR
    • change library code
    • run “rake nuget”
    • run “Update-Package library” in the consuming application
    • build/test!

If you manually execute any of this process, especially copying files, you will find it a burden to develop the library and will find yourself dreading it, and even worse, making changes downstream instead of updating the shared library for everyone’s sake.


  • Once you have a set of changes that you want to release, consider versioning and possibly increment the minor version if needed.
  • Pick the package out of your local feed, and copy it to a public / shared feed!
    • I have a script to do this where I can drop the package on a batch file
    • Replace apikey with your nuget feed's apikey
    • Take out the confirm(s) if you don't want them
    • @ECHO off
      echo Upload %1?
      set /P anykey="Hit enter to continue "
      nuget push %1 apikey
      set /P anykey="Done "
  • Note: helps to prune all the unnecessary versions during testing from your local feed once you are done and ready to publish

  • TLDR
    • consider version number
    •   <li>run command to copy to public feed </li>