我正在使用 WixSharp 创建安装程序。我创建了一些自定义 UI,其中一个具有简单的复选框来确定安装程序是否应该覆盖配置文件。
是否可以创建自定义操作或其他会导致带有 .config 扩展名的文件不会被复制的东西?我正在尝试修改安装程序数据库,但没有成功。
有任何想法吗?谢谢
使用功能时,您可以选择执行一些操作,询问您是否检查了托管 UI 中的每个特定功能。
例如,我实现了这个 ManagedProject,我在其中决定了哪些文件要包含,哪些不根据所选的功能。这是一个例子,但由于版权限制,我不能包含整个代码。
var project = new ManagedProject($"My Tool {productVersion}",
new InstallDir(@"c:\tool",
new Dir(winServiceFeature, "admin_service",
new Files(winServiceFeature, $"{adminOutputDir}\\*.*",
f => f.EndsWith(".exe") ||
f.EndsWith(".exe.config") ||
f.EndsWith(".dll"))),
new Dir(winServiceFeature, "graph_service",
new Files(winServiceFeature, $"{graphOutputDir}\\*.*",
f => !f.Contains(".dll.config") &&
(f.EndsWith(".exe") ||
f.EndsWith("ServiceW.exe.config") ||
f.EndsWith(".dll"))),
new Dir(winServiceFeature, "simulation_service",
new Files(winServiceFeature, $"{simulationOutputDir}\\*.*",
f => f.EndsWith(".exe") ||
f.EndsWith("WebServiceW.exe.config") ||
f.EndsWith(".dll"))),
new Dir(winServiceFeature, "my_frontend",
new Files(winServiceFeature, $"{frontendDir}\\app\\*.*"),
httpWebSite,
httpsWebSite),
new Dir(winServiceFeature, "templates",
new DirFiles(winServiceFeature, $"{templatesOutputDir}\\*.*",
f => f.EndsWith("common_functions.xml")),
new Dir(firstCustomerFeature, "customer1",
new Files(firstCustomerFeature, $"{templatesOutputDir}\\customer1\\*.*",
f => f.EndsWith(".xml"))),
new Dir(secondCustomerFeature, "customer2",
new Files(secondCustomerFeature, $"{templatesOutputDir}\\customer2\\*.*",
f => f.EndsWith(".xml"))),
new Dir(@"%ProgramMenu%\My Suite\My Tool",
new ExeFileShortcut("Uninstall My Tool", "[System64Folder]msiexec.exe", "/x [ProductCode]")),
launcherInstallServiceAction,
launcherUninstallServiceAction,
adminInstallServiceAction,
adminUninstallServiceAction,
graphInstallServiceAction,
graphUninstallServiceAction,
simulationInstallServiceAction,
simulationUninstallServiceAction,
installCertificatesAction,
uninstallCertificatesAction);
在此示例中,我使用 f => f.EndsWith() 过滤器在输出中过滤我想要的文件。我还使用 new DirFiles() 仅从特定目录中获取文件。
我认为您应该在此链接中查看示例:
或者
无需自定义操作。复选框应该有一个与之关联的属性。根据此属性调节包含配置文件的组件。