28 January 2008

"Code Camp 9: I Came, I Saw, I Coded" dates announced

Chris Bowen (Microsoft Developer Evangelist for the Northeast) has announce that the dates and location for Code Camp 9 have been finalized. 

"Can you believe we're on Code Camp Nine?! Code Camps began in New England in 2004, and here we are, with Code Camps now happening all around the world!  A great testament to the motivation and strength of our global .NET developer community.

I'm happy to say we're officially a lock for April 5th and 6th for Code Camp 9 at the Microsoft offices in Waltham, MA."            - Chris Bowen

While a pithy tagline has yet to be applied to this event, Chris and his cadre of colleagues are hard at work brainstorming.  It will be interesting to see what comes out of the process. ;-)

As a prior attendee, I highly encourage you to attend if you have the time.  It is a day of Code, the whole Code and nothing but the Code.  No marketing-schlock here!

Also if you are looking to get into technical speaking, watch this space (or Chris' Blog) for the Call for Speakers.  Code Camps are a great way to get into speaking in front of a friendly audience with little pressure.  (Since the event is free, the audience really can't complain if you stink).  Chris will be opening up the speaker selection process in the near future.  I believe that he uses a "pulse-based" method for selecting speakers.  If you have a pulse, you're in!  (Sorry about letting out your secret Chris).

 

Update:  29-Jan - added pithy tagline

18 January 2008

Great dialogs from Visual Studio

I was working with a client on creating unit tests for their web services.  I wanted to run the test to see how it worked.  I hit F5 by mistake, starting the app for debugging.  I then triggered the web service test to start.  Once I realized that I had started the app, I stopped the debugging session.  It seems that this caused an unusual thing to occur, it place the Cassini web server into a "zombie state" where the only recourse it to "terminate them." 

In every zombie movie I've ever seen, you can only terminate them by blowing them up or lighting them on fire and such.  I was hesitant to click the "Yes" (defaulted) button for fear of destroying the clients machine. ;-)

Anyway, I got over my fears, clicked Yes and all is now well.  But isn't that a great dialog?

- Steve

16 January 2008

Team Build 2008 Tidbit: Setting SkipLabel to True will cause work item association to be skipped

An interesting item came across my email today.  It seems that if you set the SkipLabel property to True you get the side effect of disabling the association of workitems with those builds.

The reason behind this is that the work item association feature will compare the LastGoodLabel property (applied after each successful build) on the build definition with the current build label to determine the changesets that went into this build.  No label, no changeset list.

On the plus side, you really shouldn't be associating changesets with builds that can never be recreated anyway so this is really a good thing.

Thanks to Martin Woodward for the tidbit.

Safe Practices for Team Build

Before and since publishing my last post an email discussion thread has been going on surrounding the modification of what I'll call the "Serviceable Components" of Team Build.  It's probably a good start to define what a "Serviceable Component" is with regard to Team Build. 

Serviceable Component:  A file or assembly that may be updated by a future version or service pack of Visual Studio/Team Foundation Server.  E.g.:

  • Microsoft.TeamFoundation.Build.targets
  • TFSBuild.proj template file found in VSInstallDir\Common7\IDE\PrivateAssemblies\1033

The original question was how to create an easily maintainable build that contained certain consistent pieces, such as always adding a specific Property or always overriding a specific Target.  Discussion ensued and began revolving around the best practices for creating an easily maintainable Team Build and what the boundaries should be in creating one.  Each of the participants noted that they had seen certain "risky behaviors" at their clients.  I found that each wound up giving fairly consistent advice to mitigate that risk. 

Some of the common "Safe Practices" (and reasons) that have come out of this discussion are as follows:

  1. Never directly modify the Microsoft.TeamFoundation.Build.targets file. 
    • This file can/will/has been updated by later versions of Team Foundation Server. 
    • If this file is modified, an upgrade may fail since this is a text file that does not contain a version resource.  If the date/time stamp of the modified version is newer that the date/time stamp of the version being installed, the installer will not overwrite it. 
    • If this file cannot be upgraded when you upgrade your TFS, it will be out of sync and (at best) your Team Builds will begin to fail completely or (at worst) your Team Build will continue to work but give incorrect output that needs to be tracked down.
  2. Never directly modify the template file for TFSBuild.proj (VSInstallDir\Common7\IDE\PrivateAssemblies\1033).
    • Same problems apply as the Microsoft.TeamFoundation.Build.targets file above.
    • This file is heavily tied to a specific version of Microsoft.TeamFoundation.Build.targets.

There are always exceptions to any rule and these are no different. There are too many constraints to believe that everyone can work within these practices.  The intention of this post is to allow the reader to walk into these situation with the knowledge to understand the risks that they are accepting so that a risk mitigation plan can be created/acted upon.

13 January 2008

Team Build: Modify template that creates TFSBuild.proj file

A question came up recently about a common problem in organizations that utilize Team Build.  The problem was that there are some common Properties or Targets that must be added to every build.  They want to make it as easy as possible to ensure that these Properties/Targets are added.  As is usual, there were some constraints.  The first is that the Microsoft.TeamFoundation.Build.targets is off-limits to modification.  This is a generally accepted "best practice" as Microsoft does not guarantee that this file will remain the same between versions, and in fact has changed between TeamBuild 2005 and TeamBuild 2008.  The second constraint was that they wanted a way to add these "common elements" without having to go and manually check-out and modify each and every TFSBuild.proj file.

A solution that meets these constraints and solves the problem is to modify the Visual Studio template that is used to create the TFSBuild.proj files when you create a new team build type. 

IMPORTANT:  This template is in the PrivateAssemblies folder for Visual Studio.  As such, it can and likely will be overwritten during Visual Studio maintenance (e.g. Service Packs or KB updates).  As such, any changes you make here may be lost so it is important to check the resulting TFSBuild.proj file after the wizard ends.  Just like the Microsoft.TeamFoundation.Build.targets file, it is not a best practice to modify these files.

The template can be found in: 

[VS2005] C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\1033\tfsbuild.proj
[VS2008] C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\1033\tfsbuild.proj

Below are the (heavily edited) contents of the VS 2005 template.  As you can see, some of the values are static and some contain replaceable parameters (like Description) which are updated after the New Team Build Type wizard closes. 

To add your common Targets and Properties all you have to do is edit this file and then install it on each machine that will be creating Team Build Types. So if you always need to override the BeforeGet target, all you have to do is put your override target into a custom target file (say MyCustomBuild.targets) and then Import it after the Microsoft.TeamFoundation.Build.targets Import (like below).  To add custom Properties or ItemGroups, just add them right into the Template file at the appropriate location.

<?xml version="1.0" encoding="utf-8"?>
<Project>
  <!-- COMMENTS REMOVED  -->

  <!-- Do not edit this -->
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0
\TeamBuild\Microsoft.TeamFoundation.Build.targets
" />
  <!-- My Corporate Customizations -->
  <Import Project="$(MSBuildExtensionsPath)\MyCompany\MyCustomBuild.targets" />
  <PropertyGroup>
<!--
PUT CUSTOM PROPERTIES HERE -->
<
MyCustomProperty>ACustomPropertyValue</
MyCustomProperty>
</PropertyGroup>

  <ProjectExtensions>
    <!--  DESCRIPTION
     The description is associated with a build type. Edit the value for making changes.
    -->
    <Description>$description$</Description>

    <!--  BUILD MACHINE
     Name of the machine which will be used to build the solutions selected.
    -->
    <BuildMachine>$build machine name$</BuildMachine>
  </ProjectExtensions>

  <PropertyGroup>
    <!--  TEAM PROJECT
     The team project which will be built using this build type.
    -->
    <TeamProject>$Team Project name$</TeamProject>

    <!--  BUILD DIRECTORY
     The directory on the build machine that will be used to build the
     selected solutions. The directory must be a local path on the build
     machine (e.g. c:\build).
    -->
    <BuildDirectoryPath>$Build Directory (c:\build)$</BuildDirectoryPath>

    <!--  DROP LOCATION
      The location to drop (copy) the built binaries and the log files after
     the build is complete. This location has to be a valid UNC path of the
     form \\Server\Share. The build machine service account and application
     tier account need to have read write permission on this share.
    -->
    <DropLocation>$drop location (e.g. \\Server\share)$</DropLocation>

    <!--  TESTING
     Set this flag to enable/disable running tests as a post build step.
    -->
    <RunTest>$true/false$</RunTest>

    <!--  WorkItemFieldValues
      Add/edit key value pairs to set values for fields in the work item created
      during the build process. Please make sure the field names are valid 
      for the work item type being used.
    -->
    <WorkItemFieldValues>Symptom=build break;Steps To Reproduce=Start the build using Team Build</WorkItemFieldValues>

    <!-- REMAINING PROPERTIES REMOVED  -->
</PropertyGroup>
  <!-- REMAINING ITEMGROUPS REMOVED -->

</Project>

Just remeber that you have to install the updated Template tfsbuild.proj file to each machine that will create new Team Build types.  Also note that this will not do anything for Team Build types that have already been created, just new ones.

Many thanks to Team System MVPs Neno Loje and Marcel De Vries for the question and the answer, respectively.

 

Edited:  Added Caveat section warning about use of this technique.

02 January 2008

Come 'n get it! - The January TFS Times has been published

Paul Hacker has just published the January edition of the TFS Times newsletter.  This is a monthly newsletter devoted to topics in and  around Team Foundation Server.  This month's topic is Team Build, next month's is Dev Tools.

01 January 2008

Reset Association between Changesets and Builds

I was catching up on some MSDN Build Automation forum posts recently and came across a very interesting question by Wayne Sepega.  I have run across the same problem a couple of times in the past and haven't had a good answer until now.

Here is a scenario that we are facing with the TFS Build and the way change sets are associated with builds.

Each build generates an MSI and the MSI is moved from environment to environment.

     1) We get a request to do some work

     2) The work is completed and changes are checked into TFS, as a result of the work over a few days there are 5 change sets.

     3) A build (build 1) is done, and deployed to QA, the 5 changes are associated with Build 1

     4) QA finds a bug in Build 1

     5) Bug is fixed which results in 2 change sets

     6) A Build (build 2) is completed and deployed to QA

     7) Build 2 passes QA and is then promoted to Production and deployed.

In the above scenario there are actually 7 change sets that need to be noted in the deployment to production. However, the final build, Build 2, only has the last two change sets associated with it.
Is there a built in way in TFS to have all outstanding change sets associate with a build once the build quality is promoted? Is there a built in way to get a list of change sets for a build type based on the build quality?

Basically I need to find a way to know about ALL 7 change sets with the final build, without having to do a separate build script for each environment as we want to deploy exactly what QA tests and not rebuild.

Thanks

Wayne

This is a fairly common scenario for an organization that uses a Binary Promotion process to move their application through environments. 

Binary Promotion is a methodology in which a build occurs and the resulting binary code is packaged together (zip, msi, etc) and stamped with a unique name usually containing a version or build number.  This package is then given to QA to deploy to their environment and test.  If anything is found to be wrong with the application, the entire package is thrown out and another version (hopefully with a fix) is built, packaged and promoted to QA.  Once the app passes QA, it is promoted to Production by sending the exact package that was tested in QA to the IT group for installation on the Production Servers, thus "promoting" the binary package through the enviromnents.

Aaron Hallberg responded that the "good build" flag is responsible for associating changesets with a build.  This means that a changeset only gets associated with a build if that build completes successfully.  The good build flag is implemented by a bit field aptly named GoodBuildFlag located in the Builds table of the TFSBuild database.  To get access to this flag, you call the BuildStore.UpdateFlags method.  Passing false to the UpdateFlags method will reset the GoodBuildFlag and reset the association. 

TFS Version Control Tidbit: How to ban a specific file extension from version control

To make it difficult for a user to add/check-in a file of a specific type, you can use the Forbidden Patterns  check-in policy from the Team Foundation Server Power Tools for TFS 2008. 

Forbidden Patterns Policy
Allows you to specify a file extension or a regular expression that you can use to keep certain file types from being checked in to source control. This policy is most useful for DLL-files, build artifacts, or automatically-generated Web site files that are generated automatically during development. Versioning these files is not appropriate since they are on demand and specific to the development environment. The Forbidden Patterns policy scans each of the file names on check-in. It determines if there is a match. If there is a match, the check-in is blocked.

While this isn't foolproof (policy can be overridden), it does raise the bar.

The Forbidden Patterns Policy can be downloaded as part of the Team Foundation Power Tools for TFS 2008 from the MSDN site.

 

- Steve