Items and when are they filled

Hi there

Looking for some help on this...

If I was to create an Items collection in the following way:

<ItemGroup>

<TestAssemblies Include="**.tests.dll"/>

</ItemGroup>

When would the values be assigned to the collection

I intend this to contain a list of all my unit test and I am then going to use this as input to my unit test target, but I am unsure if the collection would be populated when MSBuild is executed, when the collection is encountered or when its first reference.

Thanks

Andy



Answer this question

Items and when are they filled

  • simon_p

    Thanks for the information, this sorted my problem.

    Andy


  • Rogerio Sobreira

    Since items are evaluated before any target is executed, if you need to include files that your targets create you'll have to use the CreateItem task. This allows you to dynamically create (append to existing) items. The expressions contained in these tasks are evaluated as the task executes.

    Sayed Ibrahim Hashimi
    www.sedodream.com

  • Glenn Davis

    When MSBuild executes the project it will do the evaluation of the properties and Items in the following manner:

    • First evaluate the properties
    • Second evaluate the Items
    • Thrid evaluate the targets

    This means that if you put the code below in, 

    <ItemGroup>

             <TestAssemblies Include="**.tests.dll"/>

    </ItemGroup>

    TheTestAssemblies will be filled with all of the tests.dll 's that existed prior to any targets being run. 

    Also **.tests.dll will not do anything, you need to do **\*.tests.dll if you want to find all the *.tests.dll in the current directory and all nested directories

    So it should be:

    <ItemGroup>

             <TestAssemblies Include="**\*.tests.dll"/>

    </ItemGroup>


  • Items and when are they filled