Now if you’re going around creating custom XML files for USMT to use, you bound to come across an issue of precedence at some point. for the most part, USMT is pretty good at processing rules as they were designed, however you will see the odd issue. Here is one such example.
Say you want to want to migrate everything from the C:Fastrack directory, except for AVI files, you might create a rule like this;
<component type="Documents" context="System">
<displayName>Fastrack Technology Data Rule</displayName>
<role role="Data">
<rules>
<include>
<objectSet>
<pattern type="File">C:Fastrack* [*]</pattern>
</objectSet>
</include>
<exclude>
<objectSet>
<pattern type="File">C:* [*.avi]</pattern>
</objectSet>
</exclude>
</rules>
</role>
</component>
so, you’d expect this rule to migrate everything under C:Fastrack except for files anywhere on C: that have an AVI extension, right?
…… wrong!! in this case, one of the precedence rules will come into play. where a conflict exists between an <include> and an <exclude>, the rule with a more specific context will win. In this case, C:Fastrack* [*] is more specific than C:* [*.avi] so the <exclude> will not be applied. OK, so what? I hear you ask, why not just change the <exclude> to C:Fastrack* [*.avi], problem solved… in fact that is what you would do…. in this case….. but what about a component like this.
<component type="Documents" context="System">
<displayName>Fastrack Technology Data Rule</displayName>
<role role="Data">
<rules>
<include>
<objectSet>
<pattern type="File">C:Fastrack* [*]</pattern>
<pattern type="File">C:FastrackData* [*]</pattern>
<pattern type="File">C:FastrackFiles* [*]</pattern>
</objectSet>
</include>
<exclude>
<objectSet>
<pattern type="File">C:* [*.avi]</pattern>
<pattern type="File">C:* [*.wmv]</pattern>
<pattern type="File">C:* [*.mov]</pattern>
<pattern type="File">C:* [*.mp4]</pattern>
</objectSet>
</exclude>
</rules>
</role>
</component>
You see? now all of a sudden you’ll need to create 12 patterns in the <exclude> instead of 4, one for each folder in the <include>, for each extension you want to exclude. In a recent case I’ve been working on, there is a list of almost 400 file extensions that need to be excluded, with 3 folders in the <include>, having to repeat the list over and over has caused significant clutter in the XML. Worth noting, if you are ok with excluding the pattern from the entire migration, not just the component in question, then you can use the <unconditionalexclude> flag, more info here.
More info on USMT conflicts and precedence can be found on TechNet.