tags:

views:

47

answers:

1

Dear ladies and sirs.

Observe the following piece of an msbuild script:

<ItemGroup>
  <R Include="-Microsoft.Design#CA1000" />
  <R Include="-Microsoft.Design#CA1002" />
</ItemGroup>

I want to convert it to

/ruleid:-Microsoft.Design#CA1000 /ruleid:-Microsoft.Design#CA1002

Now, the best I came up with is @(R -> '/ruleid:%(Identity)'), but this only yields

/ruleid:-Microsoft.Design#CA1000;/ruleid:-Microsoft.Design#CA1002

Note the semi-colon separating the two rules, instead of a space. This is bad, it is not recognized by the fxcop - I need a space there.

Now, this is a simple example, so I could just declare something like this:

<PropertyGroup>
  <R>/ruleid:-Microsoft.Design#CA1000 /ruleid:-Microsoft.Design#CA1002</R
</PropertyGroup>

But, I do not like this, because in reality I have many rules I wish to disable and listing all of them like this is something I wish to avoid.

+2  A: 

To delimit each item by using a character other than a semicolon, use the syntax @(myType, 'separator')

<ItemGroup>
  <R Include="-Microsoft.Design#CA1000" />
  <R Include="-Microsoft.Design#CA1002" />
</ItemGroup>

<Target Name="FxcopRulesFlattening">
  <!-- Using the syntax @(ItemName, 'Separator')-->
  <Message Text="@(R -> '/ruleid:%(Identity)', ' ')"/>
</Target>
madgnome
Excellent. Thank you very much.
mark