xml - MSBuild: How can I check are the files existing? -


ms visual studio 2012; msbuild.

i getting error (error msb4184) if files ain't exist. trying set condition, ending in invalid syntax... please find below code proj-file:

<target name="resources">     <generateresource condition = " $([system.io.directory]::getfiles(&quot;$(msbuildprojectdirectory)\resources&quot;,&quot;*.*&quot;, system.io.searchoption.alldirectories)::length) != 0 "         sources="$(msbuildprojectdirectory)\resources\**\*.*">         <output taskparameter="outputresources"             itemname="resources"/>     </generateresource> </target> 

this condition the:

system.io.directory.getfiles("$(msbuildprojectdirectory)\resources","*.*", system.io.searchoption.alldirectories).length 

how can solve problem?

thank you.

i think can check condition , itemgroup declaration below:

<target name="resources">     <itemgroup>       <packagefiles include="$(msbuildprojectdirectory)\resources\**\*.*;"/>     </itemgroup>     <generateresource condition="exists('%(packagefiles.fullpath)')" sources="@(packagefiles)">         <output taskparameter="outputresources" itemname="resources"/>     </generateresource> </target> 

probably may need customizations in output tag per requirement.


Comments