在Inno Setup中使用通配符查找目录 [英] Find a directory using wildcard in Inno Setup
问题描述
我正在尝试在Inno Setup脚本的目录名称内使用通配符时递归获取目录中的所有文件.
I'm trying to get all the files in a directory recursively while using wildcard within the name of the directory in Inno Setup script.
我碰到过有关文件名的示例,但没有关于目录搜索的示例.
I have came across examples for filename but none for a directory search.
用例: 基本上,我们已经将NuGet软件包用于内部开发项目.因此,每个项目都会制作一个NuGet软件包,其他项目和/或开发人员可以使用该软件包.
Use Case: Basically, we have moved to using NuGet packages for our internal development projects. So each project makes a NuGet package which can be consumed by other project and/or developer.
其中一部分,我们希望使用Inno Setup来使用NuGet包中的dll和/或文件.
Part of this we wish to use the Inno Setup to use the dlls and/or files from a NuGet package.
例如,我们需要找到与"../packages/PackagesA.../"
相匹配的包文件夹,例如"PackageA v1.2.0"
.
For example, we need to find the package folder matching "../packages/PackagesA.../"
, e.g. "PackageA v1.2.0"
.
在这个中如何在Inno Setup安装程序中捆绑来自NuGet软件包的仅运行时依赖项?几乎完全是我想要的,但是该代码似乎在我的Inno Script中不起作用.
Came across this How to bundle run-time-only dependencies from NuGet packages in Inno Setup installer?, which is almost exactly I want but it seems the code doesn't work in my Inno Script.
对如何解决此问题有任何帮助或建议吗?
Any help or suggestion as how to approach this?
推荐答案
您可以定义 Inno Setup预处理器将解析目录文件掩码的功能.为此使用 FindFirst
函数:
You can define an Inno Setup preprocessor function that will resolve the directory file mask. Use FindFirst
function for that:
#define FindFolder(Path) \
Local[0] = FindFirst(Path, faDirectory), \
Local[0] ? AddBackslash(ExtractFileDir(Path)) + FindGetFileName(Local[0]) : Path
[Files]
Source: "{#FindFolder("..\packages\PackagesA*")}\*.*"; DestDir: "{app}"; \
flags: recursesubdirs
如果在脚本末尾添加 SaveToFile
调用:
If you add SaveToFile
call to the end of the script:
#expr SaveToFile(AddBackslash(SourcePath) + "Preprocessed.iss")
...您将看到上面的代码解析为:
... you will see that the above code resolves to:
[Files]
Source: "..\packages\PackageA1.2.0\*.*"; DestDir: "{app}"; flags: recursesubdirs
如果找不到此类文件夹,则代码解析为:
If no such folder is found, the code resolves to:
[Files]
Source: "..\packages\PackageA*\*.*"; DestDir: "{app}"; flags: recursesubdirs
...,然后编译器将失败,并显示找不到与...匹配的文件"..
... and the compiler will then fail with "No files found matching ...".
这篇关于在Inno Setup中使用通配符查找目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!