MSbuild Copy whole folder

前端 未结 7 756
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-03 17:43

trying to copy a whole folder, but when i do this:


相关标签:
7条回答
  • 2021-02-03 18:32

    For me what worked was this: - kept folder structure - copied all files within the folder - works for any folder, doesn't have to be in the project or the same project folder

    <ItemGroup>
        <_CopyItems Include="<path relative to project>\**\*.*" />
    </ItemGroup>
    
    <Target Name="AfterBuild">
      <Copy SourceFiles="@(_CopyItems)" DestinationFiles="@(_CopyItems->'$(OutDir)\<output folder>\%(RecursiveDir)%(Filename)%(Extension)')"/>
    </Target>
    

    legend:

    • <path relative to project>: this could be any path, using ..\ for going above the proj folder works
    • <output folder>: folder you want the whole file structure to be dropped into, excluding the source folder.
    • $(OutDir) will be bin\Debug or whatever build mode you have, if you want something else, change that.
    0 讨论(0)
提交回复
热议问题