The intersection of technology and leadership

Faster MSBuild Scripts – Convert ItemGroup to CreateItem

Speed, speed, speed… I wish MS tools would give me faster and faster feedback.

My lesson from last week – stay far away from ItemGroup elements in MSBuild files for most normal fileset equivalents (most especially if they only get used once). They are far better as CreateItem elements (though unfortunately only declarable within a Target element), taking almost the same syntax.

The result – instantaneous execution of any other targets outside of the one that uses these items, and a quicker ability to fail faster if you mistype the target name. Maybe it’s time to convert all of our targets to Nant?

1 Comment

  1. Troy Gould

    Another good reason to use CreateItem instead of ItemGroup is that ItemGroup is evaluated at startup of msbuild. This can cause all kinds of problems if you want to use an ItemGroup after another Target has, for example, created some files that should belong to the ItemGroup. CreateItem evaluates at runtime. So, those new files will be picked up by the time you use the CreateItem task.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2024 patkua@work

Theme by Anders NorenUp ↑