c# - Is there another way to copy hundreds of files during build other than with a post-build step or using Copy to Output Directory? -
i have c# dll project containing hundreds resources have copied in place exe project see them. these resources cannot embedded in dll.
i know how create post-build step copy files.
mkdir $(targetdir)\special xcopy /s /e /y /c $(projectdir)\special $(targetdir)\special the problem post-build step copies files output directory of dll. not copy output directory of exe. need of in output directory of exe. furthermore, there 2 exe projects in solution , there more.
i seem recall there way tell msbuild (or visual studio) these hundreds of files copied final output directory of whatever referencing dll.
there property called "copy output directory" appears work. trouble there hundred of files, several people work on this, , if messes 1 file, system break. discovering single file out of hundreds had little property flipped wrong way going troublesome.
update
i tried ideas mentioned below , found few things...
idea 1 (@guyvdn)
put in project somewhere
<itemgroup> <myspecialfiles include="special\**\*" /> </itemgroup> and above closing </project> tag:
<target name="afterbuild"> <makedir directories="$(outputpath)\special" condition="!exists('$(outputpath)\special')" /> <copy sourcefiles="@(myspecialfiles)" destinationfiles="@(myspecialfiles->'$(outputpath)\special\%(recursivedir)%(filename)%(extension)')" /> </target> idea 2 (@user704808)
put in project somewhere
<itemgroup> <myspecialfiles include="special\**\*" /> </itemgroup> and above closing </project> tag:
<target name="setcopytooutputdirectoryonresourceitems" beforetargets="build"> <itemgroup> <embeddedresource> <copytooutputdirectory>always</copytooutputdirectory> </embeddedresource> <myspecialfiles condition="'%(myspecialfiles.extension)'=='.py'"> <copytooutputdirectory>always</copytooutputdirectory> </myspecialfiles > </itemgroup> </target> problems
- neither 1 copies special\ folder exe's output directory.
- idea 1 outputs special\ dll's output directory only
- idea 2 did not output @ all. :-(
update 2
@jimmy's idea worked perfect. clean build didn't remove files.
maybe easier use post-build step of each exe project instead of dll project. way $(targetdir) should correct. source directory can use $(solutiondir) , append folder name of resources it.
another option create own msbuild script (walkthrough: creating msbuild project file scratch), way can use more powerful copy task.
Comments
Post a Comment