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
This is how you can inject the required XML it in your case:
However the next Wix# release will have a method extension that will simplify the task a little
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")); }
document.Select("Wix/Bundle") .AddWixFragment(new XElement(WixExtension.Util.ToXName("FileSearch"), @"Variable=AdobeInstalled; Result=exists; Path=[ProgramFilesFolder]Adobe\\...\\adobe.exe".ToXAttributes()));