简体   繁体   English

在 Inno Setup 中使用通配符查找目录

[英]Find a directory using wildcard in 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.我试图在 Inno Setup 脚本中的目录名称中使用通配符时递归地获取目录中的所有文件。

I have came across examples for filename but none for a directory search.我遇到过文件名的例子,但没有遇到过目录搜索的例子。

Use Case: Basically, we have moved to using NuGet packages for our internal development projects.用例:基本上,我们已经开始将 NuGet 包用于我们的内部开发项目。 So each project makes a NuGet package which can be consumed by other project and/or developer.因此,每个项目都会制作一个 NuGet 包,可供其他项目和/或开发人员使用。

Part of this we wish to use the Inno Setup to use the dlls and/or files from a NuGet package.其中一部分我们希望使用 Inno Setup 来使用 NuGet 包中的 dll 和/或文件。

For example, we need to find the package folder matching "../packages/PackagesA.../" , eg "PackageA v1.2.0" .例如,我们需要找到匹配"../packages/PackagesA.../"的包文件夹,例如"PackageA v1.2.0"

Came across this How to bundle run-time-only dependencies from NuGet packages in Inno Setup installer?遇到了这个如何在 Inno Setup 安装程序中从 NuGet 包中捆绑仅运行时依赖项? , which is almost exactly I want but it seems the code doesn't work in my Inno Script. ,这几乎正是我想要的,但似乎代码在我的 Inno Script 中不起作用。

Any help or suggestion as how to approach this?关于如何解决这个问题的任何帮助或建议?

You can define an Inno Setup preprocessor function that will resolve the directory file mask.您可以定义一个Inno Setup 预处理器函数来解析目录文件掩码。 UseFindFirst function for that:为此使用FindFirst函数

#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  

If you add SaveToFile call to the end of the script:如果将SaveToFile调用添加到脚本末尾:

#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 ..." . ...然后编译器将失败并显示"No files found matching ..."

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM