问题描述
我使用MSBuild拥有以下文件集:
I have the following set of files with MSBuild:
<ScriptFiles Include="Server/scripts/**/*.js" />
然后我将所有内容复制到另一个目录:
I then copy all of it over to another directory:
<Copy SourceFiles="@(ScriptFiles)" DestinationFiles="@(ScriptFiles->'$(BuildDir)/WWW/scripts/%(RecursiveDir)%(Filename)%(Extension)')" />
但是,我要复制的是 *.js
,然后复制的/yui/*.*
.我尝试做的是:
However, what I want to do is copy *.js
, and copy /yui/*.*
. What I tried doing is:
<ScriptFiles Include="Server/scripts/**/*.js;Server/scripts/yui/**/*" />
但是,这样做是将/yui/
目录展平,并将yui的所有文件直接放入/WWW/scripts
.
However, what this does is flatten the /yui/
directory and put all of yui's files directly into /WWW/scripts
.
有更好的方法吗?
顺便说一句,我实际上是在使用 XBuild
而不是 MSBuild
,但是从我所看到的来看,两者在大多数情况下是兼容的.
BTW, I'm actually using XBuild
and not MSBuild
, but from what I've seen the two are for the most part compatible.
推荐答案
更新了Ritch的注释(我添加了Exclude,以避免两次复制相同的文件):
Updated Ritch's comment (I added Exclude to avoid copying the same files twice):
不应该是两个单独的行:
Shouldn't that be two separate lines:
<ScriptFiles Include="Server/scripts/**/*.js" Exclude="Server/scripts/yui/**/*"/>
<YuiFiles Include="Server/scripts/yui/**/*" />
OR
<YuiFiles Include="Server/scripts/yui/**/*" />
<ScriptFiles Include="Server/scripts/**/*.js" Exclude="@(YuiFiles)"/>
<Copy SourceFiles="@(YuiFiles)" DestinationFiles="..." />
<Copy SourceFiles="@(ScriptFiles)" DestinationFiles="..." />
这篇关于用MSBuild递归复制所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!