Quantcast
Channel: wixsharp Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1354

New Post: Placing an executable and an MSI in a bundle, in a bootstrapper

$
0
0
Indeed typically Wix# produces the all required XML behind the scene so you don't need to deal with raw XML.

However if some WiX features are not supported directly then you may need to define the corresponding XML explicitly (see InjectXML sample). The same applies to the fragments. The fragments are pure XML decoration feature of WiX and as such it's hard to map it to the object model of the Wix# project definition.

This is how you can inject the required XML it in your case:
bootstrapper.WixExtensions.Add("WixUtilExtension");
bootstrapper.WixNamespaces.Add("xmlns:util=\"http://schemas.microsoft.com/wix/UtilExtension\"");
bootstrapper.WixSourceGenerated += Bootstrapper_WixSourceGenerated;
...
staticvoid Bootstrapper_WixSourceGenerated(System.Xml.Linq.XDocument document)
{
    var ns = document.Root.GetNamespaceOfPrefix("util");

    document.Root.Add(new XElement("Fragment",
                            new XElement(ns + "FileSearch")
                                .AddAttributes(@"Id=AdobeSearch;
                                                Variable=AdobeInstalled;
                                                Result=exists;
                                                Path=[ProgramFilesFolder]Adobe\\...\\adobe.exe")));

    document.Select("Wix/Bundle/Chain")
            .AddBeforeSelf(new XElement(ns+"FileSearchRef")
                                .SetAttribute("Id=AdobeSearch"));
}
However the next Wix# release will have a method extension that will simplify the task a little
document.Select("Wix/Bundle")
        .AddWixFragment(new XElement(WixExtension.Util.ToXName("FileSearch"),
                                   @"Variable=AdobeInstalled;
                                     Result=exists;
                                     Path=[ProgramFilesFolder]Adobe\\...\\adobe.exe".ToXAttributes()));

Viewing all articles
Browse latest Browse all 1354

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>