简体   繁体   中英

WixSharp: How to exclude files from copying to destination directory?

I am using a WixSharp to create Installer. I have a few custom UI created and one of them has simple checkbox to determine if installer should override config files.

It is possible to create custom action or something else which would cause that the files with the .config extension will not be copied? I was trying with modifying installer database with no luck.

Any ideas? Thanks

When you use Features, you have the choice to perform some actions asking if you have checked or not checked every particular feature in a Managed UI.

For example, I implemented this ManagedProject, where I decided which files to include and which not according the selected feature. This is as an example, but I cannot include the whole code because copyright restrictions.

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);

In this sample, I use f => f.EndsWith() filters to filter the files I want at the output. I also use new DirFiles() to get only files from an specific directory.

I think you should see the examples at this links:

WildCard sample from WixSharp

or

List directories issue at WixSharp

No custom action needed. The check-box should have a property associated with it. Condition the component containing the config file based on this property.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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