0

I know I can do the following

<PropertyGroup>
    <Foo>Bar</Foo>
    <Foo1>Bar1</Foo1>
    <Foos>$(Foo) $(foo1)</Foos>
</PropertyGroup>

<Target Name="Def">
    <Message Text="$(Foos)"/>
</Target>

and get Bar Bar1

But this doesn't scale very well if you have many properties in the PropertyGroup.

Is there any way to reference a PropertyGroup or some other node and have MSBuild do the hard work for you?

I know the PropertyGroup element doesn't support it but imagine being able to do

<PropertyGroup Name="Bob">
    <Foo>Bar</Foo>
    <Foo1>Bar 1</Foo1>
</PropertyGroup>

<Target Name="Def">
    <Message Text="$(Bob)"/>
</Target>

and get Bar Bar 1

4

1 回答 1

1

这可以使用 ItemGroup 和@()符号来实现。

例子

<ItemGroup>
    <Foo Include="Bar"/>
    <Foo Include="Bar1"/>
</ItemGroup>

<Message Text="@(Foo)"/>

印刷Bar;Bar1

请注意@,默认情况下,符号以分号连接项目。我们可以使用第二个参数将其更改为@(..).

<ItemGroup>
    <Foo Include="Bar"/>
    <Foo Include="Bar1"/>
</ItemGroup>

<Message Text="@(Foo, ' ')"/>

印刷Bar Bar1

于 2013-07-24T13:41:31.703 回答