Navigation

Search

Categories

On this page

if (Orcas == 11/15/2007) { /* begin download */}
Debugging Custom Build Tasks in Team Build
Microsoft ESB Guidance for BizTalk Server 2006 R2
Deleting Multiple Builds from Team Foundation Server

Archive

Blogroll

Disclaimer
None - these are my opinions and they're also my employer's!

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 14
This Year: 0
This Month: 0
This Week: 0
Comments: 15

Sign In

 Saturday, November 10, 2007
Sunday, November 11, 2007 6:55:13 AM (Mountain Standard Time, UTC-07:00) ( )

Is Don Box saying what I think he's saying?  That might just give us enough time to get it all downloaded from MSDN before the parades and football games!

Comments [1] | | # 
Sunday, November 11, 2007 6:27:19 AM (Mountain Standard Time, UTC-07:00) ( )

Have you ever had one of those ideas pop in your head that makes you feel stupid and brilliant at the same time?  I had just such a situation the other day when I was working to debug some custom tasks I'd written.  The tasks were fairly simple - checking out and back in some assemblies that had just been compiled during a Team Build. 

I followed the MSDN documentation for creating a custom task and used the TFS SDK to perform the necessary actions to create pending edits and check in the changes.  I fired up MSBuild and ran the build locally after deploying my assembly to the appropriate folder and identifying the task in my build script.  Of course, things didn't quite go right as the log file showed.  Thinking how easy this was going to be to fix, I set a breakpoint in the first line of the Execute override and anticipated the excitement of seeing the debugger spring to life. 

I was running MSBuild at the command prompt and passing in all the parameters that I needed to run the script.  I switched over to the command prompt, started MSBuild, then switched back to Studio to attach to the process.  Needless, to say this wasn't working.  Had I been as bright as I could have been I would have found this article from 2005!!!! and saved myself some heartburn.  Alas, I didn't feed the Google monster just the right words and all I got in return were bunny trails. 

Left to my own devices I thought if only I had time to attach to the MSBuild process before my task ran I would be able to catch the breakpoint.  Well, I do know how to slow something down so I decided to create a new custom task for pausing the build allowing me enough time to attach to the process and begin the debug prior to the custom task completing.  I came up with the following:

    public class Pause : Task
    {
        public Pause() { }
 
        private int _milliseconds;
        [Required]
        public int Milliseconds
        {
            get { return _milliseconds; }
            set { _milliseconds = value; }
        }
 
        public override bool Execute()
        {
            if (_milliseconds > 0)
            {
                Thread.Sleep(_milliseconds);
            }
            return true;
        }
    }

I registered the task and called it from my build script right before the custom task I was trying to debug:

    <Target Name="BeforeCompile">
        <Pause Milliseconds="20000" />
        <Checkout CheckoutItems="@(SharedAssembliesPathsToUpdate)" />
    </Target>

Now I had adequate time to get to the debugger and find my boneheaded mistakes.  Ended up being an easy change and then things worked great.

Ever the optimist, I commented out the pause task execution and checked in my TFSBuild.proj file so I could run the build on the build machine.  I kicked off the Team Build Type in Team Explorer and kaput.  It died before it really began.

Fortunately, I had VS2005 loaded on the build machine so I fired it up, uncommented my pause task invocation, checked it back in to TFS, kicked off the build, attached to the MSBuild.exe process that the Team Build Service started and hit my breakpoint.  The problem ended up being related to the Team Build temporary workspace and some incorrect assumptions on my part about how it was created and how the mappings would work.  Once I got that figured out everything ran as expected.

Is this solution elegant?  Probably not.  But it is simple and occasionally simplicity is elegant in its own right.

P.S. Don't forget to remove any calls to the pause task as this has the obvious side effect of slowing down your builds!

Comments [1] | | # 
 Friday, November 09, 2007
Saturday, November 10, 2007 7:15:27 AM (Mountain Standard Time, UTC-07:00) ( )

Microsoft patterns & practices has just delivered an ESB Guidance package for creating an Enterprise Service Bus using BizTalk Server 2006 R2.  You can read about it here.

It would be interesting to know if this is in line with the path to Oslo.  Christian Weyer has a post which describes some of that vision.  It's interesting that this latest push for formal SOA from Microsoft (remember EDRA & EDAF?) doesn't appear to explicitly include an ESB path.

Comments [1] | | # 
 Monday, November 05, 2007
Monday, November 05, 2007 9:25:01 PM (Mountain Standard Time, UTC-07:00) ( )

I've been working a lot with Team Foundation Server lately (2005, unfortunately) doing builds and have created a bunch of test builds out on my client's TFS.  I knew the easiest way to delete builds was using the TFSBuild.exe utility but I couldn't find any help on how to send multiple build numbers to the utility on the command line.  I saw a couple of references that said to separate them with commas but that didn't work - it appeared to interpret the concatenated list as one build number.

So, I tried using spaces between each build number and that worked.  Hopefully, this will help anyone else trying to clean up their build messes.  I have a feeling things would have been quite a bit easier had I worked in TFS 2008 but my client couldn't wait until they brought that upgrade into their environment.

Example below: (be sure to use quotes if build names contain spaces)

C:\>tfsbuild delete http://tfsserverurl:8080 "Team Project Name" Development_RC1.3.4 Development_RC1.3.5 Development_RC1.3.6 Development_RC1.3.7 /noprompt

Microsoft (R) TfsBuild Version 8.0.0.0
for Microsoft (R) Visual Studio 2005 Team System
(C) Copyright 2006 Microsoft Corporation. All rights reserved.

Deleting Development_RC1.3.4... Done

Deleting Development_RC1.3.5... Done

Deleting Development_RC1.3.6... Done

Deleting Development_RC1.3.7... Done

Comments [1] | | #