tags:

views:

68

answers:

2

If I create a list of Items in a MSBuild file is the order of the items maintained when passed to a task?

E.g. a list of database script files is specified in an ItemGroup. I then feed this ItemGroup to a custom task? Will the order be guaranteed or could the order change?

A: 

I believe the order is maintained. However, depending on how you create the ItemGroup the order there may not be guaranteed.

To be more complete you should probably build the scripts with the Depends group to try and get them in some order, i.e. Reference Data insertion depends on the stored proc scripts which depends on the schema scripts. You could define each as an ItemGroup and thus the order will be correct.

But you can probably safely assume that the order is maintained if you build them the same way each time.

David McEwing
A: 

Yes, MSBuild maintains the order of a list of items that have the same item type within an ItemGroup. (For example, the order of all the "<Compile Include="...">" in a .fsproj matters, as it specifies the order of files in the F# project file.)

Brian
Is there anything in the MSDN documentation that says this?
PenFold
I don't know, but I work at MS on Visual Studio, and I talked to the developers of MSBuild to get this information (as I needed to understand this guarantee to author the F# project system implementation).
Brian
Ok, that's great.
PenFold