使用 msbuild 复制所有文件和文件夹 [英] Copy all files and folders using msbuild

查看:32
本文介绍了使用 msbuild 复制所有文件和文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道是否有人可以帮助我编写一些我正在尝试编写的 msbuild 脚本.我想要做的是使用 msbuild 将所有文件和子文件夹从一个文件夹复制到另一个文件夹.

Just wondering if someone could help me with some msbuild scripts that I am trying to write. What I would like to do is copy all the files and sub folders from a folder to another folder using msbuild.

{ProjectName}
      |----->Source
      |----->Tools
              |----->Viewer
                       |-----{about 5 sub dirs}

我需要做的是将工具文件夹中的所有文件和子文件夹复制到应用程序的调试文件夹中.这是我到目前为止的代码.

What I need to be able to do is copy all the files and sub folders from the tools folder into the debug folder for the application. This is the code that I have so far.

<ItemGroup>
    <Viewer Include="..$(ApplicationDirectory)Toolsviewer***.*" />
</ItemGroup>

<Target Name="BeforeBuild">
    <Copy SourceFiles="@(Viewer)" DestinationFolder="@(Viewer->'$(OutputPath)\Tools')" />
</Target>

构建脚本运行但不复制任何文件或文件夹.

The build script runs but doesn't copy any of the files or folders.

谢谢

推荐答案

我也在寻找这方面的帮助.我花了一段时间,但这是我所做的非常有效的方法.

I was searching help on this too. It took me a while, but here is what I did that worked really well.

<Target Name="AfterBuild">
    <ItemGroup>
        <ANTLR Include="..Dataantlrcs***.*" />
    </ItemGroup>
    <Copy SourceFiles="@(ANTLR)" DestinationFolder="$(TargetDir)\%(RecursiveDir)" SkipUnchangedFiles="true" />
</Target>

这会递归地将名为 antlrcs 的文件夹的内容复制到 $(TargetDir).

This recursively copied the contents of the folder named antlrcs to the $(TargetDir).

这篇关于使用 msbuild 复制所有文件和文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆