WixSharp:如何从复制目标目录中排除文件?

时间:2018-04-01 12:02:44

标签: c# wix wixsharp

我正在使用WixSharp来创建安装程序。我创建了一些自定义UI,其中一个具有简单的复选框,以确定安装程序是否应覆盖配置文件。

可以创建自定义操作或其他会导致不会复制扩展名为.config的文件的操作吗?我试图修改安装程序数据库而没有运气。

有什么想法吗? 感谢

2 个答案:

答案 0 :(得分:1)

使用功能时,可以选择执行一些操作,询问是否已检查受管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()从特定目录中仅获取文件。

我认为您应该在以下链接中看到示例:

WildCard sample from WixSharp

List directories issue at WixSharp

答案 1 :(得分:0)

无需自定义操作。复选框应具有与之关联的属性。根据此属性调整包含配置文件的组件。