仅复制将另一个文件作为同级的文件[基于扩展]?
我正在尝试使用ANT将C ++构建的一些文件复制到另一个目录中。
构建的输出看起来像这样:
/Build
/LibA
LibA.lib
LibA.pdb
/LibB
LibB.lib
LibB.pdb
/ProjA
myexe.exe
myexe.pdb
/Foo
foo.exe
foo.pdb
/...
现在,我想复制所有*。EXE
文件及其*。pdb
文件(但不是*。pdb libs的文件)。
我尝试了:
<copy todir="outdir">
<fileset dir="Build">
<include name="**/*.exe" />
<include name="**/*.pdb" />
</fileset>
</copy>
但是,我还将在liba,libb,...文件夹中获得*。pdb
文件。
有什么方法我只能复制具有*。exe
-file的PDB文件,与他们的兄弟姐妹相同的目录?
不幸的是,这些文件夹的命名不得以任何方式允许基于文件夹名称使用通配符。
当然,我可以单独列出每个文件,例如:
<include name="ProjA/*.pdb" />
<include name="Foo/*.pdb" />
<!-- ... -->
但是,我认为也许有一种优雅的方式可以指定“复制所有*。Exe
exe 文件和所有**。 pdb
在其旁边有*。exe
文件的文件”。
I am trying to use ANT to copy some files of a C++ build into another directory.
The output of the build looks like this:
/Build
/LibA
LibA.lib
LibA.pdb
/LibB
LibB.lib
LibB.pdb
/ProjA
myexe.exe
myexe.pdb
/Foo
foo.exe
foo.pdb
/...
Now, I would like to copy all *.exe
files and their *.pdb
files to another directory (but not the *.pdb
files of the libs).
I tried with:
<copy todir="outdir">
<fileset dir="Build">
<include name="**/*.exe" />
<include name="**/*.pdb" />
</fileset>
</copy>
However, then I will also get the *.pdb
files inside the LibA, LibB, ... folders.
Is there any way I can only copy the pdb-files which have an *.exe
-file in the same directory as their sibling?
Unfortunately, the folders are not named in any way that would allow using wildcards based on the folder name.
Of course, I could list each file individually, such as:
<include name="ProjA/*.pdb" />
<include name="Foo/*.pdb" />
<!-- ... -->
However, I am thinking that maybe there is an elegant way where I can specify "copy all *.exe
files and all *.pdb
files which have an *.exe
file next to them".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用选择器要查找“兄弟姐妹”文件,类似的内容:
这只会复制具有匹配.EXE文件的.pdb文件。
为了使其简单,请为EXE文件使用单独的文件集。
仅当您只需要复制忽略源目录结构的文件时,才需要平坦的映射器。
You could use the
<present>
selector to find the "sibling" files, something like this:This will only copy the .pdb files with matching .exe files.
To keep it simple, use a separate fileset for the exe files.
The flatten mapper is only needed if you want to copy just the files ignoring the directory structure in the source.