Lets say I have the following folder structure
可以说我有以下文件夹结构
app
-->folder1
----->subfolder2
----->subfolder3
-->folder2
----->subfolder4
-->folder3
And I want to use the Copy
task to copy folder2
(including subfolders) and subfolder3
to my output.
我想使用Copytask将folder2(包括子文件夹)和子文件夹3复制到我的输出。
How can I achieve that? Btw, I'm using MSBuild for a PHP website, and in the real situation there are a lot more subfolders and specific folders I want to copy.
我怎样才能做到这一点?顺便说一下,我正在使用MSBuild来建立一个PHP网站,在实际情况下,我想复制更多子文件夹和特定文件夹。
2 个解决方案
#1
3
Create an item group with folder2
and subfolder3
in it and then use the copy
task.
在其中创建包含folder2和子文件夹3的项目组,然后使用复制任务。
For example:
<ItemGroup>
<sourceFiles Include="app\folder1\subfolder3\**\*.*" />
<sourceFiles Include="app\folder2\**\*.* />
</ItemGroup>
<Copy SourceFiles="@(sourceFiles)" DestinationFolder="c:\output\%(RecursiveDir)"></Copy>
#2
1
You could try RoboCopy:
你可以试试RoboCopy:
<UsingTask AssemblyFile="MSBuild.ExtensionPack.dll" TaskName="MSBuild.ExtensionPack.FileSystem.RoboCopy"/>
<MSBuild.ExtensionPack.FileSystem.RoboCopy
Source="$(YourSourcePath)"
Destination="$(YourOutputPath)"
Files="*.*"
Options="/MIR"/>
The /MIR
option duplicates the whole folder tree including empty folders
/ MIR选项复制整个文件夹树,包括空文件夹
Robocopy reference:
MSBuild扩展包
#1
3
Create an item group with folder2
and subfolder3
in it and then use the copy
task.
在其中创建包含folder2和子文件夹3的项目组,然后使用复制任务。
For example:
<ItemGroup>
<sourceFiles Include="app\folder1\subfolder3\**\*.*" />
<sourceFiles Include="app\folder2\**\*.* />
</ItemGroup>
<Copy SourceFiles="@(sourceFiles)" DestinationFolder="c:\output\%(RecursiveDir)"></Copy>
#2
1
You could try RoboCopy:
你可以试试RoboCopy:
<UsingTask AssemblyFile="MSBuild.ExtensionPack.dll" TaskName="MSBuild.ExtensionPack.FileSystem.RoboCopy"/>
<MSBuild.ExtensionPack.FileSystem.RoboCopy
Source="$(YourSourcePath)"
Destination="$(YourOutputPath)"
Files="*.*"
Options="/MIR"/>
The /MIR
option duplicates the whole folder tree including empty folders
/ MIR选项复制整个文件夹树,包括空文件夹
Robocopy reference:
MSBuild扩展包