merge - Merging two item groups using MSBuild -
i have 2 questions:
how can filter list of files (in itemgroup) extension?
i have 2 lists of files read out of xml files via xmlpeek merge based on conditional. can done in msbuild?
currently, have this:
<target name="getexportfilelist"> <!-- can't use xpath filter value extension because msbuild doesn't support xpath 2.0's ends-with() function --> <xmlpeek xmlinputpath="$(xmlfile)" query = "//file[not(./@value = '') , not(./@value = preceding::file/@value)]/@value"> <!-- file list have files 2 different extensions, we'll call them .ext1 , ext2 files - need way split 2 itemgroups each containing 1 of file types --> <output taskparameter="result" itemname="referencedfiles" /> </xmlpeek> <!-- .ext2 files xml , contain references other .ext1 files --> <xmlpeek xmlinputpath="$(directlyreferencedext2files)" query="//ext1[not(./@filepath = '')]/@filepath"> <output taskparameter="result" itemname="indirectlyreferencedext1files" /> </xmlpeek> <!-- combine 2 lists --> <itemgroup> <allext1files include="@indirectlyreferencedext1files" /> <allext1files include="@directlyreferencedext1files" exclude="@allext1files" /> </itemgroup> </target>
so recap:
- i need way extract files of type .ext1 , .ext2 referencedfiles directlyreferencedext1files , directlyreferencedext2files respectively (since can't use xpath 2.0 query in msbuild)
- take directlyreferencedext1files , indirectlyreferencedext1files (which pulled directlyreferencedext2files) , merge them 1 list processing.
there's simple way this, i'm having trouble groking how msbuild works , find reference i'm trying (msdn more confusing helpful :))
thanks!
this standard msbuild functionality:
<itemgroup> <referencedfiles include="a.ext1;b.ext1;c.ext2;d.ext2"/> </itemgroup> <target name="filterit"> <itemgroup> <directlyreferencedext1files include="%(referencedfiles.identity)" condition="'%(extension)'=='.ext1'" /> <directlyreferencedext2files include="%(referencedfiles.identity)" condition="'%(extension)'=='.ext2'" /> <allofthem include="@(directlyreferencedext1files);@(directlyreferencedext2files)" /> </itemgroup> <message text="@(directlyreferencedext1files)" /> <message text="@(directlyreferencedext2files)" /> <message text="@(allofthem)" /> </target>
note: questions duplicates because ask 2 of them it's hard find exact duplicates requires.. see how filter itemgroup? instance, , msbuild itemgroup condition, , how can merge 2 itemgroups in msbuild
Comments
Post a Comment