Deploying Web Apps with a customized Build Process in TFS

Use the steps below to setup the TFS Build server to copy built website(s) to a given directory(s)

1. Creating a new Build Definition

To setup an automatic build and deploy action, a customized build process template is required.  Setup a new build process template with parameters by following the steps below:

  1. Create a new Build Definition by opening up the Team Explorer panel in Visual Studio and navigating to the “Builds” portion of the tree
  2. Right click on “Builds” and choose “New Build Definition”
  3. Under the General section, supply a name. In the Build Defaults section, check the “This build copies outputs to a drop folder” check-box and select a folder somewhere. This is usually a share (Make sure that the “NT AuthorityNetwork service” (or whatever account the Build Controller runs under) has read/write permission here)
  4. In the Process section , set the value for “Projects to build” to the .sln file of the project you want built
  5. Under the Configurations to build section entry, set the build configuration (debug, release, dev, etc) you want built.  You will need to create a separate build definition for each configuration you want built.
Setting the properties for the Build Definitio

2. Creating a new Build Definition

  1. At the top of the Process section, there is a section that says “Build Process template”. Click on the “show details” on the right hand side of the screen and then click on the “New” button.  Choose “copy and existing XAML file” and enter a new file name
  2. In the source explorer, go to the “Build Process Templates” section under the project.  The new XAML file should be in there. Double-clicking this file will open it up in the Work flow designer.
  3. Create new input arguments for the Build Definition by selecting the “Variables” tab at the bottom of the screen and entering a new variable titled “DeployWebsiteTo” Set it as an “In” variable with a String Data-type.  (Note the image below shows two new variables titled DeployBusinessWebsiteTo and DeployPresentationWebsiteTo)
Creating new input variables

3. Creating new activities in the Build Process Template

  1. Click on the “Expand All” link on the upper right hand side of the pane. Scroll down until you find a box title “If DropBuild and DropLocation is set”. Open the toolbox and scroll down to the toolbox section labeled “Control Flow”. Drag an “If” activity onto the arrow below the “If Dropbuild..” section located above.
  2. In the Toolbox scroll to the section labeled “Team Foundation Build Activities” and drag a “CopyDirectory” action to the “Then” side of the “If” activity created in the work-flow.
  3. Right-click the icon in the new Copy Director and open the “properties” page. In the “Destination” field type the name of the variable created as an input parameter above “(DeployWebsiteTo)”. For the ”DisplayName” set it to “Copy Directory”. Under the Source enter the source directory as follows, substituting the name for your web application ‘BuildDetail.DropLocation + “_PublishedWebsitesWebsiteName”‘
  4. Close the properties for the Copy Directory activity and Open the ‘If’ Activity. Set the DisplayName to ‘If DeployWebsiteTo is set’ and the Condition field to ‘Not String.IsNullOrEmpty(DeployWebsiteTo)’
  5. Close the properties window and save the Build Definition
Creating the new build activities
Setting the Build Activity properties

4. Customizing the build Process

  1. Open the new Build Process if it isn’t already loaded and go to the Process section. Expand the “Build Process Template” by clicking the show details and make sure the new Build Definition created above is selected.
  2. Expand the ‘4. Misc’ section of the “Build Process Parameters” to see the new parameter created above. Set the directory (share) where the website should be deployed to.  Ensure the user account hat the Build Controller runs as has read/write access to this folder”. Save the Build Process.
  3. Queue a new build and verify that the website is copied to the directory specified in the parameters. You cannot change the DeployWebsiteTo” parameter when queuing a new build, it must be done by editing the build process.


The moment

My definition of a happy freelancer is knowing that at any time you could get up and do something else but the work at that moment is so invigorating, so interesting that you can’t help but be totally immersed and caught up in the task at hand.   I’m in that spot every day. ( Of course, 3pm beers on Thursday is an exception where I force myself to disengage for a brief escape! )


My Pledge to the earth 2010

Dear Earth:

I want to show you that I’m serious about treating you better and helping my fellow earthlings change their ways as well. My pledge to you this year is:

  • To reduce my consumption by 15% across the board:  15% less electrical use, 15% less km driven in my vehicles, 15% less unnecessary stuff bought from the store.
  • Bike to all destinations within 4km of my house 80% or more of the time.
  • Completely eliminate shopping at big chains that sell cheap-quality, non-local goods.  Why should I support Wal-mart when they get their apples across the border and their strawberries from 1500km away? I have fantastic orchards, farms and grocery stores all around me.
  • Extend my consumption life-cycle.  For example, new laptop every 4 years instead of every 3.
  • Resist societal pressure that  ‘new is better.’  Continue to drive  my 22-year old (well-maintained) vehicle runs on a 40% bio-diesel mix (unlike new cars which are limited to 5% and require additional energy to manufacture)
  • Buy quality items instead of cheap throw-away items whenever possible.  No more cheap crappy e-bay laptop batteries that last three months before needing to be tossed (recycled).
  • Judge my success a year from now by how much less “stuff” I have and by how much less is in my recycle, garbage and compost each week (20% less)
  • Encourage my friends and colleagues to move towards a more minimalist lifestyle that requires less stuff, smaller houses.
  • Post an article once a month on twitter/blog to spread the word globally that simple living is not only better for our planet but also healthy and liberating.

The “Feel-good” hour

Anyone who knows me should realize that I consider myself  eco-friendly.  I’m a religious (almost compulsive) recycler, I walk and bike as much as I can and even have a compost pile in  my back yard.  Yet I didn’t “celebrate” Earth hour.  Why?  Well I think that being environmentally friendly is a lifestyle choice, not something you act out once a year like Christmas Eve.  And while I completely  respect  the idea behind the hour to raise awareness on our electricity usage, I think it has  the  unintended effect of making people feel good about themselves without really accomplishing much. “Oh yeah, I’m helped the earth out, right after I ate a HUUUGE steak for supper”

Even if a person shut down ALL of their electrical devices for that hour, they only reduced their annual consumption by a measly 0.0114%!!  And I’ll bet the very next day, they’ll return to the same mega-consumption that we North Americans are so good at.  Wal-mart, Home Depot, and Costco are going to be just as busy on Mar 28 as they were the day before.

If you REALLY want to be more gentle on the earth, there are lot more ways to do it but its going to take some sacrifices. I’ve got a couple of ideas that will take more than one hour of effort per year on your part:  Walk, drive, take the bus.  Drink tap water instead of bottled. Live in a smaller house closer to the places you spend your time (work, grocery store, etc). Look at your energy consumption from all angles. Do you really need to buy/operate that leaf blower/pressure-washer/Magic Bullet? How much garbage do you throw out and what does that say about your consumption?   Do you over-eat and then drive to a gym where you run on an electrical treadmill?  Buy LESS instead of recycling MORE.

Again, not trying to be a whole downer on the concept of being more eco-friendly.  I’m glad there is an event like this to raise awareness.  I just think more people come out of this event thinking they ‘did their part’ rather than making significant lifestyle changes.

[edit: I’m going to make a future comment on corporations using this event as a PR opportunity.  Dimming your lights for an hour does little to show me your environmental awareness]