I started playing with MSBuild this weekend. It’s a little under-documented for my taste, but seems rather powerful. It has a strange combination of functional and procedural styles which make some simple tasks relatively complex.
This is the first in what I hope will be a series of posts of solutions that I’ve worked through for MSBuild. Keep in mind that I am still an MSBuild beginner, so there may be a better way to solve these problems.
Given one ItemGroup (including metadata), how can one choose a subset of the items, keeping metadata intact? The subset is determined by a property that is actually a list of keys.
Projects to build: First;Third (arguments: 1;3)
By default, this example decides to build the first and third projects. However, passing /p:Projects=”First;Second” will change to the first and second projects (shown below). The metadata is preserved, as shown by displaying the arguments.
Projects to build: First;Second (arguments: 1;2)
About Stephen Cleary
Stephen Cleary is a Christian, husband, father, and programmer living in Northern Michigan.