My Automated NuGet Workflow
Posted
by Wes McClure
on Geeks with Blogs
See other posts from Geeks with Blogs
or by Wes McClure
Published on Thu, 08 Nov 2012 20:44:28 GMT
Indexed on
2012/11/08
23:02 UTC
Read the original article
Hit count: 292
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.
Building
- 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
- AssemblyInfo –> [assembly: AssemblyVersion("1.0.*")]
- 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
- Setup library assembly version to auto increment build and revision
- 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| msb.properties :configuration => :Release msb.targets :Build msb.solution = $projectSolution end task :nuget => [:build] do sh "nuget pack src\\Library\\Library.csproj /OutputDirectory " + $nugetFeedPath end
- 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.
Publishing
- 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
- run command to copy to public feed
© Geeks with Blogs or respective owner