.NET Framework Bookmark and Share   
 index > MSBuild > Itemgroup works hard when it shouldn't
 

Itemgroup works hard when it shouldn't

We are(were) experiencing about a 5 second delay in msbuild startup, between the copyright banner and the first output. I tracked it down today and came up with a simple repro.

It appears that an ItemGroup element will do the search on disk before examining conditions. If conditions are false, then the search is discarded, but on our build tree each search of the tree is a couple of seconds, and we had a couple of different searches going on at startup.

Looking further I find that if I put the ItemGroup inside a target it works like It should. The following sample takes 2 seconds to run on my quad core, but if the ItemGroup is moved inside a target it's a qtr of a second.

Running Win2k3 Sp2 Server x64 EE , .net 3.5 sp1. Others have reproduced on various XP's etc so don't think it's a particular machine issue.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="3.5" >

<Target Name="Build" >
<Message Text="Hello world @(ProjectFiles)" />
</Target>

<ItemGroup Condition="'n' == 'y'">
<ProjectFiles Condition="1==2" Include="l:\**\msbuild.*.proj" />
</ItemGroup>
</Project>

  • Edited bySteve Dillon Wednesday, September 02, 2009 10:23 PMFIx OS description
  •  
Steve Dillon
Hi Steve

Unfortunately this is a bug in MSBuild. As you've determined, the workaround is to move the ItemGroup inside a Target. You could look into setting the InitialTargets property to call a Target which gets all your files and you can guarantee that they are correctly evaluated.

This bug is resolved in the MSBuild 4.0 beta bits...

Regards

Mike
  • Marked As Answer bySteve Dillon Friday, September 04, 2009 2:02 PM
  •  
Mike Fourie
I can repro that. Looks like a bug. I'll try find out more. Mike
Mike Fourie
Hi Steve

Unfortunately this is a bug in MSBuild. As you've determined, the workaround is to move the ItemGroup inside a Target. You could look into setting the InitialTargets property to call a Target which gets all your files and you can guarantee that they are correctly evaluated.

This bug is resolved in the MSBuild 4.0 beta bits...

Regards

Mike
  • Marked As Answer bySteve Dillon Friday, September 04, 2009 2:02 PM
  •  
Mike Fourie
Thanks, I moved them off to Targets and knocked about 10 minutes off of an 1:45 build time.

Steve
Steve Dillon

You can use google to search for other answers

Custom Search

More Threads

• Is there a way to use wild cards within an "Exec command..."?
• Multiple Solutions Per Team Build Type - Best Practice?
• MSBuild -> Web Deployment Project
• Building solution with file system based webservices with Msbuild
• What's the best way to support a C compiler in MSBuild?
• Dynamic Templates
• Why a project using System.IdentityModel.Claims(.Net3.0+) built successfully when it targeting .NetFramework 2.0
• AssemblyInfoTask errors
• build error with devenv
• how to copy files to another location