Friday, September 04, 2009 5:29 PMI have a problem. I have 2 directory structures. Which effectively mirror each other and I need to reconcile them as a matter of process. I need to list everything in directory A that isn't in directory B, recurisively.
So I create an item for directory B but how do I work it into the exclude for item A? I need that recurisive directory structure but the syntax is giving me grief since I have to shift it to match directory A. Any ideas?
Monday, September 07, 2009 9:28 AMModeratorHi Lou,
How about writing a custom task to do this job? The input of the task will be two item list and the output will be one item list of different items.
In order to write a custom task, please refer to: http://msdn.microsoft.com/en-us/library/t9883dzc.aspx.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Tuesday, September 08, 2009 7:21 AMHi Lou,
Basically you could take item A which contains all files in directory A and subtract item B (all files in directory B) from it. You then get an item C that only contains files that are not listed in item B, i.e. that are not in directory B. In MSBuild you can do it as follows:
< CreateItem Include = " @(DirectoryA) " Exclude = " @(DirectoryB) " >
< Output TaskParameter = " Include " ItemName = "FilesNotInDirectoryB " />
</ CreateItem >
Tuesday, September 08, 2009 1:39 PMModeratorI don't think that will work as the paths will be different so the Exclude will not match the items. A custom task is probably required.
Tuesday, September 08, 2009 4:10 PM
I figured it out. As Mike said the the directory paths don't match. However through some monkeying around I managed to use the exclude by taking advantage of the recursive dir property. Check this out:
<Output TaskParameter="Include" ItemName="Directory2Files"/>
<CreateItem Include="$(SolutionRoot)\directory1\**\*.*" Exclude="@(Directory2Files->'$(SolutionRoot)\directory1\%(RecursiveDir)%(Filename)%(Extension)')">
<Output TaskParameter="Include" ItemName="Directory1Files"/>
I have to say it, I love MSBuild!
- Marked As Answer by Lou Machado Tuesday, September 08, 2009 4:10 PM