c# - Condition using File::Exists not working -


i create first msbuild-script.

i've tag "folders" findes directories in given root path:

<?xml version="1.0" encoding="utf-8"?> <project defaulttargets="build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" toolsversion="4.0">   <target name="build">     <propertygroup>       <rootfolder>tmp</rootfolder>     </propertygroup>     <itemgroup>       <folders include="$([system.io.directory]::getdirectories(&quot;$(rootfolder)&quot;))"/>     </itemgroup>     <message text="@(folders -> '%(fullpath)\bin\debug\%(filename)%(extension).dll', ';')"/>   </target> </project> 

that works perfect. problem need directories specified file exists. tried condition that

condition="$([system.io.file]::exists(&quot;%(fullpath)\\bin\\debug\\%(filename)%(extension).dll&quot;))" 

for folder tag.

this script runs without error list empty. why?

are there other solutions check file?

i used solution because uses c# , i'm c#-developer.

<?xml version="1.0" encoding="utf-8"?> <project defaulttargets="build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" toolsversion="4.0">   <target name="build">     <propertygroup>       <rootfolders>tmp</rootfolders>     </propertygroup>     <getfiles rootfolders="$(rootfolders)">       <output propertyname="files" taskparameter="files" />     </getfiles>     <message text="$(files)" />   </target>    <usingtask       taskname="getfiles"       taskfactory="codetaskfactory"       assemblyfile="$(msbuildtoolspath)\microsoft.build.tasks.v4.0.dll">       <parametergroup>         <rootfolders parametertype="system.string" required="true" />         <files parametertype="system.string" output="true" />       </parametergroup>       <task>           <using namespace="system" />           <using namespace="system.io" />           <using namespace="system.linq" />           <code type="fragment" language="cs">               <![cdata[                                  func<string, string> buildfilepath = path => path + @"\bin\debug\" + path.getfilename(path) + ".dll";                   var dirs = directory.getdirectories(rootfolders).where(x => file.exists(buildfilepath(x)));                   files = string.join("\n", dirs.select(buildfilepath));               ]]>           </code>       </task>   </usingtask> </project> 

afaik, thing condition executed , checked whole declaration of items (i.e. <folders ..> tag).

i think, need loop through collection (e.g. using target/task batching) , check file exist in every single folder folder in collection. if file exists - include in new <foldersfiletered> items collection.

nb: don't have time test code now, idea roughly:

<target name="filterfolders"     inputs="@(folders)"     outputs="%(fullpath)">     <itemgroup>     <foldersfiltered include="@(folders->'%(fullpath)')"         condition="$([system.io.file]::exists(&quot;@(folders->'%(fullpath)'\\bin\\debug\\yourfile.dll&quot;))" />     </itemgroup> </target> 

Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -