Welcome to MSDN Blogs Sign in | Join | Help

Answer to the Batching Brainteaser

Earlier this week I posted a little batching brainteaser from our internal team discussion list. If you have a cheesy drumroll sound on your computer now is the time to start playing it, 'cause here comes the answer:

a) 0

Yep, that's right, zero. Thomas is the winner for giving the correct answer twice, for two very different reasons (one of which actually made me laugh out loud). The reasoning in his second answer is roughly correct.

When using metadata during batching with an item name, such as '%(Foo.Identity)'=='%(Bar.Identity)', the item name is included in the comparison. Since "foo" never equals "bar" the condition in the example is always false and nothing gets printed.

To make the XML print three lines, which is what you'd expect, you actually don't have to use a condition at all. You just need to put %(Identity) into the message somewhere, like this:

<Message Text="@(Foo) @(Bar) %(Identity)"/>

This looks completely bizarro, I admit, but does result in the following output:

a a a
b b b
c c c

Batching. What could be more fun? Mad props to Sumedh for helping to explain all this to me.

[ Author: Neil Enns ]

Published Friday, January 27, 2006 9:12 PM by msbuild
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

Monday, January 30, 2006 9:19 AM by Team System News

# VSTS Links - 01/30/2006

James Manning gives us some ideas of what to do when someone takes a file hostage with a lock in their...

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker