Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is $([System.Text.RegularExpressions.Regex]::IsMatch()) evaluated once in ItemGroupDefinition?
    primarykey
    data
    text
    <p>So fiddling with MSBuild tasks, and I am finding that a Regex metadata property is evaluated once rather than per item.</p> <p>For example</p> <pre><code>&lt;!-- actual items, we use standard project reference items and extend via ItemDefinitionGroup. add project references through IDE to extend coverage --&gt; &lt;ItemGroup&gt; &lt;ProjectReference Include="..\Example.UnitTests-x86\Example.UnitTests-x86.csproj"&gt; &lt;Project&gt;{7e854803-007c-4800-80f9-be908655229d}&lt;/Project&gt; &lt;Name&gt;Example.UnitTests-x86&lt;/Name&gt; &lt;/ProjectReference&gt; &lt;ProjectReference Include="..\Example.UnitTests\Example.UnitTests.csproj"&gt; &lt;Project&gt;{eaac5f22-bfb8-4df7-a711-126907831a0f}&lt;/Project&gt; &lt;Name&gt;Example.UnitTests&lt;/Name&gt; &lt;/ProjectReference&gt; &lt;/ItemGroup&gt; &lt;!-- additional item properties, defined with respect to item declaring it --&gt; &lt;ItemDefinitionGroup&gt; &lt;ProjectReference&gt; &lt;Isx86&gt; $([System.Text.RegularExpressions.Regex]::IsMatch(%(Filename), '.*x86*')) &lt;/Isx86&gt; &lt;/ProjectReference&gt; &lt;/ItemDefinitionGroup&gt; &lt;!-- additional task target, invoke both x64 and x86 tasks here --&gt; &lt;Target Name="AdditionalTasks"&gt; &lt;Message Text="%(ProjectReference.Filename) Isx86 '%(Isx86)' Inline '$([System.Text.RegularExpressions.Regex]::IsMatch(%(Filename), '.*x86*'))'" Importance="high" /&gt; &lt;/Target&gt; </code></pre> <p>Produces this output</p> <pre><code>Example.UnitTests-x86 Isx86 'False' Inline 'True' Example.UnitTests Isx86 'False' Inline 'False' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload