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

查看:228
本文介绍了复制使用的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}

我需要能够做的是从工具复制所有文件和子文件夹文件夹放到应用程序的调试文件夹中。这是code,我有这么远。<​​/ P>

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)\Tools\viewer\**\*.*" />
 </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.

感谢

推荐答案

我想问题可能是你是如何创建的ItemGroup并调用复制任务。看看这是有道理的:

I think the problem might be in how you're creating your ItemGroup and calling the Copy task. See if this makes sense:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
    <PropertyGroup>
    	<YourDestinationDirectory>..\SomeDestinationDirectory</YourDestinationDirectory>
    	<YourSourceDirectory>..\SomeSourceDirectory</YourSourceDirectory>
    </PropertyGroup>

    <Target Name="BeforeBuild">
    	<CreateItem Include="$(YourSourceDirectory)\**\*.*">
    		<Output TaskParameter="Include" ItemName="YourFilesToCopy" />
    	</CreateItem>

    	<Copy SourceFiles="@(YourFilesToCopy)"
    			DestinationFiles="@(YourFilesToCopy->'$(YourDestinationDirectory)\%(RecursiveDir)%(Filename)%(Extension)')" />
    </Target>
</Project>

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

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