Welcome to MSDN Blogs Sign in | Join | Help

A Little Batching Brainteaser

Every so often as we work through converting the Visual Studio builds over to MSBuild we stumble across a little quirk or entertaining bit of MSBuild XML that makes the team scratch its head. Dan sent this one around to the team a couple of weeks ago, and it's related to our previous post about unqualified metadata.

How many x's does the following MSBuild XML produce?

<Project DefaultTargets="Build" xmlns=http://schemas.microsoft.com/developer/msbuild/2003>
    <
ItemGroup>
        <
Foo Include="a"/>
        <
Foo Include="b"/>
        <
Foo Include="c"/>
        <
Bar Include="a"/>
        <
Bar Include="b"/>
        <
Bar Include="c"/>
    </
ItemGroup>
    <
Target Name="Build">
        <
Message Text="@(Foo) @(Bar)" Condition="'%(Foo.Identity)'=='%(Bar.Identity)'"/>
    </
Target>
</
Project>

To make it easier we'll make the question multiple choice. Is the answer:

a) 0
b) 2
c) 3
d) 9

No cheating! You can't run this through MSBuild to find out. Take a guess first, then try it out.

[ Author: Neil Enns]   

Published Tuesday, January 24, 2006 7:16 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

Wednesday, January 25, 2006 11:46 AM by Thomas Freudenberg

# re: A Little Batching Brainteaser

a) 0
I don't see any 'x' in the XML :-P
Wednesday, January 25, 2006 12:43 PM by msbuild

# re: A Little Batching Brainteaser

Hahahahaha :) Ok, I suppose that's technically correct. That's what I get for cleaning up Dan's original challenge.

Let me rephrase: How many lines of output does the following MSBuild XML produce?

Neil
Wednesday, January 25, 2006 2:52 PM by fcarlier

# re: A Little Batching Brainteaser

It will try to match every element in Foo in Bar, and if they are equal, print out the name of the element.

Since there are three elements identique elements in Foo and Bar, it will print out:

a
b
c

or so I guess
Wednesday, January 25, 2006 6:21 PM by msbuild

# re: A Little Batching Brainteaser

That's definitely a reasonable guess, but not what the output winds up being (I'll explain why later :) Anyone else?

Neil
Thursday, January 26, 2006 3:41 AM by Thomas Freudenberg

# re: A Little Batching Brainteaser

I still guess 0, because Foo and Bar are never identical regardless their includes.
Monday, June 19, 2006 1:28 PM by car insurance

# re: A Little Batching Brainteaser

<a href='http://www.yahoo.com'></a> http://www.insurance-top.com/auto/">http://www.insurance-top.com/auto/ <a href='http://www.insurance-top.com'>auto insurance</a>. <a href="http://www.insurance-top.com ">Insurance car</a>: auto insurance, insurance car, Best Insurance Web site . [url]http://www.insurance-top.com/car/[/url] [link=http://www.insurance-top.com]insurance quote[/link] from site .
Monday, June 19, 2006 1:28 PM by insurance auto

# re: A Little Batching Brainteaser

http://www.insurance-top.com/company/">http://www.insurance-top.com/company/ auto site insurance. [URL=http://www.insurance-top.com]home insurance[/URL]: auto insurance, insurance car, Best Insurance Web site . [url=http://www.insurance-top.com]cars insurance[/url] from website .
Monday, June 19, 2006 1:28 PM by insurance auto

# re: A Little Batching Brainteaser

http://www.insurance-top.com/company/ auto site insurance. auto insurance, insurance car, Best Insurance Web site . from website .
Tuesday, August 08, 2006 2:05 PM by carinsurance

# re: A Little Batching Brainteaser

Thursday, August 10, 2006 2:29 PM by autoinsurance

# re: A Little Batching Brainteaser

Friday, August 11, 2006 7:04 PM by motercycle insurance

# re: A Little Batching Brainteaser

motercycle insurance <a href=http://motercycle-insurance.dreamstation.com/>motercycle insurance</a>
Monday, August 14, 2006 12:49 AM by zpiugsq@yahoo.com

# re: A Little Batching Brainteaser

ringtones free
Tuesday, August 15, 2006 1:56 AM by auto insurence

# re: A Little Batching Brainteaser

auto insurence <a href=http://www.netcolony.com/auto-insurence>auto insurence</a>

# MSBuild Team Blog A Little Batching Brainteaser | Paid Surveys

# MSBuild Team Blog A Little Batching Brainteaser | Weak Bladder

# MSBuild Team Blog A Little Batching Brainteaser | low cost car insurance

# MSBuild Team Blog A Little Batching Brainteaser | patio umbrella

# MSBuild Team Blog A Little Batching Brainteaser | debt consolidator

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker