tags:

views:

39

answers:

1

It's possible to create properties using either of these methods:

<Target Name="A">
    <PropertyGroup>
        <DogSound>Bark</DogSound>
    </PropertyGroup>
</Target>

<Target Name="B">
    <CreateProperty Value="Bark">
        <Output TaskParameter="Value" PropertyName="DogSound"/>
    </CreateProperty>
</Target>

But, what's the difference between the semantics of targets A and B, if anything?

Thanks.


Note: I'm using msbuild 3.5. I believe the PropertyGroup syntax didn't work inside a target in earlier versions of msbuild, but that was also the same with ItemGroups. CreateItem got deprecated, but CreateProperty didn't, so I'm wondering if CreateProperty still has something over using PropertyGroup, and if so, what.

+2  A: 

Don't use CreateProperty & CreateItem in MSBuild 4.0. Instead just place ItemGroup and PropertyGroup directly inside of the target.

You are correct before MSBuild 3.5 ItemGroup/PropertyGroup were not allowed inside of targets so there was CreateProperty & CreateItem tasks that people would use. After MSBuild 3.5 you should just use the ItemGroup & PropertyGroup. Although there are some extreme corner cases where you still might need CreateProperty & CreateItem, but I wouldn't worry about those. These scenarios deal with escaping and how CreateItem is less restrictive then ItemGroup. But in reality 99% of people will not face this.

Sayed Ibrahim Hashimi
Thanks for your answer, I will try and stick to PropertyGroup. However, I was really asking about the 1% of difference people will face. What are the corner cases where PropertyGroup won't do and CreateProperty is needed?
Scott Langham