Tag Archives: NuGet

NuGetter Updated for TFS 2012

image

NuGetter, which is an extension to the Team Foundation Server build process to build, package and deploy NuGet packages has been updated to work in TFS 2012.

Not only is NuGetter updated to work with TFS 2012, but additional features have been added based on user requests.

Features:

  • Operates through the TFS Build Workflow process
  • Create simple to complex NuGet Packages
  • Can execute PowerShell scripts prior to the packaging phase to organize files and set up packaging
  • Dynamic versioning of the package
  • Supports deployment to web, local drive or network share repositories
  • Uses the NuGet.exe application but does not require installing the application to the build server
  • Remotely store/manage packaging information such as versions, API Keys and NuSpec manifest files
  • Works well with TfsVersioning to version the .NET assemblies during the build process
  • Supports the creation of multiple packages during a single build process (new)
  • Supports semantic versioning (new)

Below is a sample of a build definition that uses NuGetter and TfsVersioning to create and deploy a NuGet package.

image

Using NuGet in TFS Without Committing Packages to Source Control

And, without modifying your project “*.*proj” files.

And, without storing nuget.exe in your project’s source control.

NuGet 1.6 is out and with it is a new update to Visual Studio that will update your solution and projects with some extra code and even the NuGet.exe application so that your build process will dynamically download the required NuGet packages.  Rightly so, this is in response to the request that NuGet packages not be stored in source control as they just take up space since they are always available via download.

I understand the approach that was taken (including a .targets file as well as the nuget.exe as well as updating the **proj files) however, I think all of that is unnecessary clutter if your build process can handle it alone.

So, I looked at the NuGet commands and updated the standard TFS 2010 build template to manage this additional step automatically.  With this new template, there is no need to update your solution or projects or include NuGet.exe in your project source.

The only thing you really need to change in your project source control is remove the “packages” folder from source control.  That folder will automatically be created during the build.

Even if you already have custom build templates, you should be able to copy the NuGet restore section over since it is all contained in a single sequence.

The one thing this solution does not do is download the packages locally on your dev machine.  So, if you are getting a solution from source control for the first time, you won’t get all of the references you need since the packages folder isn’t in TFS.  That is easily fixed with a simple PowerShell script that you can run locally to set you up.  All of this is provided below.

The solution:

The Template:

Download the “NuGetRestoreTemplate.xaml” template and add it to source control.  This can be anywhere -  it doesn’t need to be part of your Team Project, it just needs to be in a location where your build can access it.

NuGet.exe:

You have 3 options here.

  1. The easiest and least intrusive your build machine is to add NuGet.exe to source control.  Like the template, this does not need to be in your Team Project.  Just put it in a location where your build can access it.  You then tell the build definition where it exists in source control.  This approach makes updating NuGet.exe easy since it’s all done through source control.  You never have to get on the build machine which in some environments is next to impossible.
  2. Put it on your build server and remember the exact file path.  You can tell the build definition exactly where to look for it.
  3. Put it on your build server and add that folder to your PATH environment variable.  If you do this, then you will leave the location blank in the build definition.  It will be found automatically.  One note here: if you do this, you may have to reboot your machine so the build process realizes the right path.

One suggestion for the template and the NuGet.exe location in source control:  Create a general Team Project that will house all of your build goodies such as custom templates, custom activities and support applications.  I generally create a “BuildActivities” project and put everything in there.  You just need to give everyone read access to it.

To follow along with this recommendation, I created a “BuildActivities” Team Project.  In it I have a “BuildProcessTemplates” folder where I keep all of the generally available build templates.  I have a “NuGet” folder where I keep the “NuGet.exe” application.  I also have subfolders in here for previous releases (just in case).  I also have a folder called “Custom Activities” for all of the custom activities that my templates require.  Note: the template I created for the solution I am describing does not require any custom activities.  I just included that suggestion for completeness.

Creating the Build Definition

Creating the build definition is pretty straight forward.

  1. When you get to the Process, click “New…” next to your “Build process file:”.
  2. Click “Select an existing XAML file”
  3. Click “Browse” and navigate to where you placed the template in source control
  4. Click “OK”

image

The “NuGet Restore/Install” section will appear in the build process parameters

image

Enter the location of the NuGet.exe file.  In this example I placed it in source control but you can just as easily enter the full path on the build machine if that’s where you placed it.  Leave this blank if you put NuGet.exe on the build machine and in the “Path”.

Next, you can add the locations of where to look for the NuGet packages during download.  You can enter multiples here – just delimit with a semi-colon “;”.  If you leave this blank, NuGet will attempt to look at “%AppData%\NuGet\NuGet.config” for NuGet repositories.   Keep in mind that if you leave the parameter blank and expect the build machine to look in the config file, that location is account specific.  The ID of the build process will need to have that file available.

In my example, I included a local network share I set up as a gallery as well as the official NuGet Gallery.

The “Additional Install Arguments” is there if you want to include other parameters like “-Prerelease” or “-ExcludeVersion”.  Note: include the “-“ before each parameter.

That’s it.  You can now remove the “packages” folder from source control and do a build.

Of course, and as always, I would recommend testing this first on a sample app within your environment just to see how it works.

When you run the build, you will see in your log file something similar to this:

image

This shows that the build process has dynamically downloaded all of the required NuGet packages.

Resources:

NuGet Restore/Install/Update:

Here’s the templates and PowerShell Script:

The 2nd template I’ve provided will do the same “restore” process but will also update to the latest version of the NuGet packages rather that just the versions listed in the projects.  It is called NuGetRestoreUpdateTemplate.xaml.  Note: it may or may not break your code to use the update template depending on the version of the package that is downloaded.  See the NuGet documentation for more details.  You can include the “-safe” option in the build definition to avoid the breakage.

The PowerShell script will restore all of the NuGet packages locally if you are not storing the “packages” folder in source control:  NuGetRestore.ps1

 

My Other TFS Build Template Projects:

TfsVersioning Automated Assembly Versioning on CodePlex

NuGetter Automated NuGet Package Generation on CodePlex

NuGetter Project “Pick of the Week” on Channel 9

I just found out that Brian Keller mentioned my TFS NuGetter (CodePlex) project that automates the creation, push and publish of NuGet packages through TFS 2010  as his “Pick of the Week” on the August 19th episode of TWC9 (“This Week on Channel 9″).

You can see that episode here:  http://channel9.msdn.com/Shows/This+Week+On+Channel+9/TWC9-August-19-2011

That part was very cool.  The only thing that would’ve made it even more exciting (to me anyway) would have been if he knew who actually created it.  Oh well, it was still cool that it was his pick.  I appreciate the mention Brian!

TfsNugetter-shortened

NuGetter Build Process Version 1.0 Released

image

http://nugetter.codeplex.com/

I just released version 1.0 of NuGetter to CodePlex. Build, version, package, push and publish through an automated build in Team Foundation Server 2010.

Summary:

The NuGet project was designed to provide developers with a standardized mechanism for sharing and installing code, assemblies, etc. The creation of the packages is pretty straightforward to do in a manual way but wouldn’t it be nice if it was all automated? And, not just the packaging, the versioning and deploying should be automated as well. This way, you as the developer can create a library, build it, deploy it and immediately test it.

This is the goal of NuGetter.  It is an extension to the Team Foundation Server 2010 build process that will perform all of the necessary versioning, packaging and deployment functions in a customizable and completely repeatable way.

Capabilities:

  • Includes all phases of the build process: compile, version, pre-package, package, push/deploy and publish
  • NuGet Package and deploy features for a simple to an extremely complex library package
  • Single or multiple solution builds
  • Single or multiple configuration builds
  • Manage versioning of the assemblies coordinated or separately from the NuGet package
  • Create a package, create and push a package or create a package and push and publish to a NuGet gallery
  • Build and have immediate access to the package in a test environment through inherent “Push/Deploy” feature
  • Push locations include the NuGet Gallery, a local directory, network share or web site
  • Use in any combination of manual, continuous integration or scheduled builds
  • Ability to execute PowerShell scripts prior to packaging to organize the files (e.g., lib, tools, content) for the NuGet packaging process (pre-packaging)
  • No requirement for NuGet.exe to be installed on the build machine – NuGet.exe can be held in source control and deployed only at the time of the build
  • All of the above is managed through the standard TFS Build Workflow process
  • Remotely store/manage package information such as version numbers, API keys, and NuSpec manifest files
  • Tested with NuGet versions 1.3 and the latest 1.4 release

image

Sample build definition parameters showing amount of detailed control

image

Developer Smackdown is 2 and we just hit show #50!! How do you learn?

Thank you for the support, Developer Smackdown is 2!?!? Yes you heard it right. 50 shows in 2 years. Clark and Mark start the show musing a bit and then dive into how might you learn using NuGet as an example.

Play Episode 50 Now

Go to the show

Show Notes

Thank you for all the support over the past 2 years. For our 2 year anniversary and show #50 we went to our old watering hole, Hooters in Schaumburg. Sorry for the background noise, I guess it’s part of the experience.

Clark has been asking a lot of questions these days and the current one is “how do you learn”? Using NuGet as an example Clark and Mark explore how people might in fact learn of NuGet’s existence and why that might be the case. You can find more about NuGet at NuGet.org.

Travis and Ian, we love you guys! Keep up all the awesome you do.

Sponsors

ThatConference is a brand new conference coming to the Kalahari Resort in the Wisconsin Dells on August 13th, 14th, 15th of 2012. This is a conference is founded by Developers who want to create the conference they’ve always want to go to and for a price that’s easy to justify to your boss. First and foremost this is a developer’s conference. 3 days of any technology and nothing but code. You can find more at ThatConference.com.

WebSite Hosting is provided by Applied Innovations.

Music

ReMix.NIN.com, and http://www.podcastthemes.com/

NuGetter TFS Automated Build Process Creates and Publishes NuGet Packages

I just released to CodePlex a project that I have been working on called NuGetter. It works through Team Foundation Server automated build to help you organize the package files, create the package and then push (and even publish) to a nuget gallery.  The gallery can be the official NuGet Gallery, a local drive, network share or internal site.  Below is a description of the project which is still being developed (as of this post it is version 0.9.0.0).

http://nugetter.codeplex.com

Project Description

NuGetter is a TFS 2010 Build Process which provides packaging and deployment management to projects destined for a nuget Gallery.

Current version is 0.9.0.0. It is still undergoing development and testing although in it’s current state it is operating very well.

Capabilities/Features:

  • Build, package, push and publish simple to complex nuget packages – including multi-framework packages
  • Invoke a PowerShell script to organize or “pre-package” your files before the package step
  • Build single or multiple .net solutions as input to the packaging process
  • Deploy or Push to the nuget gallery OR an internal (localized) gallery (local or network drive, UNC share, internal web site)
  • Manage the package version directly (will be connecting the process with TfsVersioning to provide even better management of the project version)
  • Include the process as part of a continuous integration or daily build process and deploy directly to a server for testing
  • NuGet.exe is used but does NOT have to be installed on the build server so managing the server requirements is made easier
  • Manage your API Keys and store them in files OR include as part of the build definition
  • Includes custom activities and build templates to use directly within TFS

All of this is managed via a Team Foundation Server automated build.

3 Guys, 3 Helpers, NOT Three’s Company with Brandon Satrom

Clark and Mark sit down with Microsoft’s Brandon Satrom to talk through three very different implementations of an ASP.NET Helper. We dive into the dirty details of each and how come each implementation is just so different.

Listen Now: Play Here

Go to the Show Notes on DeveloperSmackdown.com

dslogo4

 

Find The Smackdown on your phone:

TheSmackdown-QR---fkdyAw[1]

DeveloperSmackdown Musing #40: I NEED HELP, HELP, HELPERS!

In this version, Clark and I muse about ASP.NET Helpers and NuGet. What are they, getting started and of course deploying.

Listen Now: Play Here

DeveloperSmackdown: Musing #40

Show Notes

The number of helpers is slowing growing.  Not only are there some good ones included with the framework but the community has started to embrace things as well.  After the show, we decided to just create the IE9 Helper we talked about.  It has since been published and you can check it out at: http://csell.net/2011/01/29/IntroducingTheIE9HelperV1.aspx. During the show we mentioned we were not aware of the actions required to have your helper listed in the WebMatrix NuGet feed. As it turns out, you just have to include the tag ‘ASPNETWEBPAGES’.  See the complete NuGet list here: http://nuget.org/Tags/ASPNETWEBPAGES

Show Links:

Make sure you hit your local grocer and pick up a 6′er of the newly released Obama beer.