Skip to content

Instantly share code, notes, and snippets.

@azyobuzin azyobuzin/proj.xml
Created Jul 28, 2018

Embed
What would you like to do?
条件に一致する最初の項目を取得しようとしてもうまくいかない例
<?xml version="1.0" encoding="UTF-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="Build">
<ItemGroup>
<FooItem Include="Foo1" Meta="A" />
<FooItem Include="Foo2" Meta="B" />
<FooItem Include="Foo3" Meta="B" />
<FooItem Include="Foo4" Meta="C" />
</ItemGroup>
<Target Name="Build">
<PropertyGroup>
<!-- $(FirstB) はバッチ実行前の値で評価されるので、これはうまくいかない -->
<FirstB Condition="'$(FirstB)' == '' AND '%(FooItem.Meta)' == 'B'">%(FooItem.Identity)</FirstB>
</PropertyGroup>
<!-- 期待した出力 → Foo2 -->
<!-- 実際の出力 → Foo3 -->
<Message Text="First: $(FirstB)" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.