Wednesday, December 12, 2007

Copy WildCards With MSBuild

I got today hysterical message from a good friend that implementing in his company automatic build with Team System. The message was: "Maor, How can I copy wildcards With MSBuild? Please help!!!".

Okay. What you should do my dear friend is:

1. Create an item list if you have more than one file to copy. You can do it with the CreateItem task:

<CreateItem Include="$(MyDir)\*.*">
<Output TaskParameter="Include" ItemName="MyFilesToCopy" />
</CreateItem>


2. Copy!



<Copy SourceFiles="@(MyFilesToCopy)" DesginationFolder="$(MyPutputDir)" />


3. Execute your build script.



Ah, by the way, if you want to recursively copy files using the <Copy> task, read this post from MSBuild Team Blog.



Enjoy!

No comments: