public static DriverInstaller Compile(this DriverInstaller driver, Project project, XElement component) { if (driver != null) { component.Add(driver.ToXml()); project.IncludeWixExtension(WixExtension.Difx); project.LibFiles.Add(System.IO.Path.Combine(Compiler.WixLocation, "difxapp_{0}.wixlib".FormatWith(driver.Architecture))); } return(driver); }
/// <summary> /// Binds the LaunchCondition to the <c>version</c> condition based on WiXNetFxExtension properties. /// <para>The typical conditions are:</para> /// <para> NETFRAMEWORK20='#1'</para> /// <para> NETFRAMEWORK40FULL='#1'</para> /// <para> NETFRAMEWORK35='#1'</para> /// <para> NETFRAMEWORK30_SP_LEVEL and NOT NETFRAMEWORK30_SP_LEVEL='#0'</para> /// <para> ...</para> /// The full list of names and values can be found here http://wixtoolset.org/documentation/manual/v3/customactions/wixnetfxextension.html /// </summary> /// <param name="project">The project.</param> /// <param name="versionCondition">Condition expression. /// </param> /// <param name="errorMessage">The error message to be displayed if .NET version is not present.</param> /// <returns></returns> static public Project SetNetFxPrerequisite(this WixSharp.Project project, string versionCondition, string errorMessage = null) { var condition = Condition.Create(versionCondition); string message = errorMessage ?? "Please install the appropriate .NET version first."; project.LaunchConditions.Add(new LaunchCondition(condition, message)); foreach (var prop in condition.GetDistinctProperties()) { project.Properties = project.Properties.Add(new PropertyRef(prop)); } project.IncludeWixExtension(WixExtension.NetFx); return(project); }
private static void ProcessCertificates(Project project, Dictionary<Feature, List<string>> featureComponents, List<string> defaultFeatureComponents, XElement product) { if (!project.Certificates.Any()) return; project.IncludeWixExtension(WixExtension.IIs); int componentCount = 0; foreach (var certificate in project.Certificates) { componentCount++; var compId = "Certificate" + componentCount; if (certificate.Feature != null) { if (!featureComponents.ContainsKey(certificate.Feature)) featureComponents[certificate.Feature] = new List<string>(); featureComponents[certificate.Feature].Add(compId); } else { defaultFeatureComponents.Add(compId); } var topLevelDir = GetTopLevelDir(product); var comp = topLevelDir.AddElement( new XElement("Component", new XAttribute("Id", compId), new XAttribute("Guid", WixGuid.NewGuid(compId)))); comp.Add(certificate.ToXml()); } }
private static void ProcessSql(Project project, Dictionary<Feature, List<string>> featureComponents, List<string> defaultFeatureComponents, XElement product) { if (!project.SqlDatabases.Any()) return; project.IncludeWixExtension(WixExtension.Sql); int componentCount = 0; foreach (var sqlDb in project.SqlDatabases) { if (sqlDb.MustDescendFromComponent) { componentCount++; var compId = "SqlDatabase" + componentCount; if (sqlDb.Feature != null) { if (!featureComponents.ContainsKey(sqlDb.Feature)) featureComponents[sqlDb.Feature] = new List<string>(); featureComponents[sqlDb.Feature].Add(compId); } else defaultFeatureComponents.Add(compId); //anchoring the generated component to the top level directory var topLevelDir = GetTopLevelDir(product); var sqlDbComponent = topLevelDir.AddElement( new XElement("Component", new XAttribute("Id", compId), new XAttribute("Guid", WixGuid.NewGuid(compId)))); var sqlDbElement = new XElement(WixExtension.Sql.ToXNamespace() + "SqlDatabase"); sqlDb.EmitAttributes(sqlDbElement); foreach (var sqlString in sqlDb.SqlStrings) { var element = new XElement(WixExtension.Sql.ToXNamespace() + "SqlString"); sqlString.EmitAttributes(element); sqlDbElement.Add(element); } foreach (var sqlScript in sqlDb.SqlScripts) { var element = new XElement(WixExtension.Sql.ToXNamespace() + "SqlScript"); sqlScript.EmitAttributes(element); sqlDbElement.Add(element); } sqlDbComponent.Add(sqlDbElement); } else { var sqlDbElement = new XElement(WixExtension.Sql.ToXNamespace() + "SqlDatabase"); sqlDb.EmitAttributes(sqlDbElement); ProcessSqlStrings(featureComponents, defaultFeatureComponents, product, sqlDb); ProcessSqlScripts(featureComponents, defaultFeatureComponents, product, sqlDb); product.Add(sqlDbElement); } } }
static void ProcessUsers(Project project, Dictionary<Feature, List<string>> featureComponents, List<string> defaultFeatureComponents, XElement product) { if (!project.Users.Any()) return; project.IncludeWixExtension(WixExtension.Util); int componentCount = 0; foreach (var user in project.Users) { //the user definition is an installed component, not only a reference if (user.MustDescendFromComponent) { componentCount++; var compId = "User" + componentCount; if (user.Feature != null) { if (!featureComponents.ContainsKey(user.Feature)) featureComponents[user.Feature] = new List<string>(); featureComponents[user.Feature].Add(compId); } else { defaultFeatureComponents.Add(compId); } //anchoring the generated component to the top level directory var topLevelDir = GetTopLevelDir(product); var userComponent = topLevelDir.AddElement( new XElement("Component", new XAttribute("Id", compId), new XAttribute("Guid", WixGuid.NewGuid(compId)))); var userElement = new XElement(WixExtension.Util.ToXNamespace() + "User"); user.EmitAttributes(userElement); userComponent.Add(userElement); } //the user definition is a reference, only else { var userElement = new XElement(WixExtension.Util.ToXNamespace() + "User"); user.EmitAttributes(userElement); product.Add(userElement); } } }
private static void ProcessDirPermissions(Dir wDir, Project wProject, Dictionary<Feature, List<string>> featureComponents, List<string> defaultFeatureComponents, XElement dirItem) { if (wDir.Permissions.Any()) { var utilExtension = WixExtension.Util; wProject.IncludeWixExtension(utilExtension); foreach (var permission in wDir.Permissions) { string compId = "Component" + permission.Id; if (permission.Feature != null) { if (!featureComponents.ContainsKey(permission.Feature)) featureComponents[permission.Feature] = new List<string>(); featureComponents[permission.Feature].Add(compId); } else { defaultFeatureComponents.Add(compId); } var permissionElement = new XElement(utilExtension.ToXNamespace() + "PermissionEx"); permission.EmitAttributes(permissionElement); dirItem.Add( new XElement("Component", new XAttribute("Id", compId), new XAttribute("Guid", WixGuid.NewGuid(compId)), new XElement("CreateFolder", permissionElement))); } } }
private static void ProcessFilePermissions(Project wProject, File wFile, XElement file) { if (wFile.Permissions.Any()) { var utilExtension = WixExtension.Util; wProject.IncludeWixExtension(utilExtension); foreach (var permission in wFile.Permissions) { var element = new XElement(utilExtension.ToXNamespace() + "PermissionEx"); permission.EmitAttributes(element); file.Add(element); } } }
XElement ServiceInstallToXml(Project project) { var serviceInstall = new XElement("ServiceInstall", new XAttribute("Id", Id), new XAttribute("Name", Name), new XAttribute("DisplayName", DisplayName ?? Name), new XAttribute("Description", Description ?? DisplayName ?? Name), new XAttribute("Type", Type), new XAttribute("Start", StartType), new XAttribute("ErrorControl", ErrorControl)); serviceInstall.SetAttribute("Account", Account) .SetAttribute("Arguments", Arguments) .SetAttribute("Interactive", Interactive) .SetAttribute("LoadOrderGroup", LoadOrderGroup) .SetAttribute("Password", Password) .SetAttribute("EraseDescription", EraseDescription) .SetAttribute("Vital", Vital) .AddAttributes(Attributes); foreach (var item in DependsOn.Split(';')) { if (item.IsNotEmpty()) { serviceInstall.AddElement("ServiceDependency", "Id=" + item); } } if (DelayedAutoStart.HasValue || PreShutdownDelay.HasValue || ServiceSid != null) { var serviceConfig = new XElement("ServiceConfig"); serviceConfig.SetAttribute("DelayedAutoStart", DelayedAutoStart) .SetAttribute("PreShutdownDelay", PreShutdownDelay) .SetAttribute("ServiceSid", ServiceSid) .SetAttribute("OnInstall", ConfigureServiceTrigger.Install.PresentIn(ConfigureServiceTrigger)) .SetAttribute("OnReinstall", ConfigureServiceTrigger.Reinstall.PresentIn(ConfigureServiceTrigger)) .SetAttribute("OnUninstall", ConfigureServiceTrigger.Uninstall.PresentIn(ConfigureServiceTrigger)); serviceInstall.Add(serviceConfig); } if (IsFailureActionSet || ProgramCommandLine != null || RebootMessage != null || ResetPeriodInDays.HasValue || RestartServiceDelayInSeconds.HasValue) { project.IncludeWixExtension(WixExtension.Util); var serviceConfig = new XElement(WixExtension.Util.ToXNamespace() + "ServiceConfig"); serviceConfig.SetAttribute("FirstFailureActionType", FirstFailureActionType) .SetAttribute("SecondFailureActionType", SecondFailureActionType) .SetAttribute("ThirdFailureActionType", ThirdFailureActionType) .SetAttribute("ProgramCommandLine", ProgramCommandLine) .SetAttribute("RebootMessage", RebootMessage) .SetAttribute("ResetPeriodInDays", ResetPeriodInDays) .SetAttribute("RestartServiceDelayInSeconds", RestartServiceDelayInSeconds); serviceInstall.Add(serviceConfig); } return(serviceInstall); }
/// <summary> /// Generates WiX XML source file the specified <see cref="Project"/> instance. /// </summary> /// <param name="project">The <see cref="Project"/> instance.</param> /// <returns>Instance of XDocument class representing in-memory WiX XML source file.</returns> public static XDocument GenerateWixProj(Project project) { project.Preprocess(); ProjectValidator.Validate(project); project.ControlPanelInfo.AddMembersTo(project); project.AutoAssignedInstallDirPath = ""; project.GenerateProductGuids(); ResetCachedContent(); string extraNamespaces = project.WixNamespaces.Distinct() .Select(x => x.StartsWith("xmlns:") ? x : "xmlns:" + x) .ConcatItems(" "); XDocument doc = XDocument.Parse( @"<?xml version=""1.0"" encoding=""utf-8""?> <Wix xmlns=""http://schemas.microsoft.com/wix/2006/wi"" " + extraNamespaces + @"> <Product> <Package InstallerVersion=""" + project.InstallerVersion + @""" Compressed=""yes""/> <Media Id=""1"" Cabinet=""" + (project as WixEntity).Id + @".cab"" EmbedCab=""yes"" /> </Product> </Wix>"); XElement product = doc.Root.Select("Product"); product.SetAttribute("Id", project.ProductId) .SetAttribute("Name", project.Name) .SetAttribute("Language", project.Language.FirstLcid()) .SetAttribute("Codepage", project.Codepage) .SetAttribute("Version", project.Version) .SetAttribute("UpgradeCode", project.UpgradeCode); if (project.ControlPanelInfo != null && project.ControlPanelInfo.Manufacturer.IsNotEmpty()) product.SetAttribute("Manufacturer", project.ControlPanelInfo.Manufacturer); product.AddAttributes(project.Attributes); XElement package = product.Select("Package"); package.SetAttribute("Description", project.Description) .SetAttribute("Platform", project.Platform) .SetAttribute("SummaryCodepage", project.Codepage) .SetAttribute("Languages", project.Language.ToLcidList()) .SetAttribute("InstallScope", project.InstallScope); if (project.EmitConsistentPackageId) package.CopyAttributeFrom(product, "Id"); package.AddAttributes(project.Package.Attributes); product.Select("Media").AddAttributes(project.Media.Attributes); ProcessLaunchConditions(project, product); //extend wDir XElement dirs = product.AddElement( new XElement("Directory", new XAttribute("Id", "TARGETDIR"), new XAttribute("Name", "SourceDir"))); var featureComponents = new Dictionary<Feature, List<string>>(); //feature vs. component IDs var autoGeneratedComponents = new List<string>(); //component IDs var defaultFeatureComponents = new List<string>(); //default Feature (Complete setup) components ProcessDirectories(project, featureComponents, defaultFeatureComponents, autoGeneratedComponents, dirs); ProcessRegKeys(project, featureComponents, defaultFeatureComponents, product); ProcessEnvVars(project, featureComponents, defaultFeatureComponents, product); ProcessUsers(project, featureComponents, defaultFeatureComponents, product); ProcessSql(project, featureComponents, defaultFeatureComponents, product); ProcessCertificates(project, featureComponents, defaultFeatureComponents, product); ProcessProperties(project, product); ProcessCustomActions(project, product); //it is important to call ProcessBinaries after all other Process* (except ProcessFeatures) //as they may insert some implicit "binaries" ProcessBinaries(project, product); ProcessFeatures(project, product, featureComponents, autoGeneratedComponents, defaultFeatureComponents); //special properties if (project.UI != WUI.WixUI_ProgressOnly) { XElement installDir = GetTopLevelDir(product); //if UIRef is set to WIXUI_INSTALLDIR must also add //<Property Id="WIXUI_INSTALLDIR" Value="directory id" /> if (project.UI == WUI.WixUI_InstallDir) product.Add(new XElement("Property", new XAttribute("Id", "WIXUI_INSTALLDIR"), new XAttribute("Value", installDir.Attribute("Id").Value))); product.Add(new XElement("UIRef", new XAttribute("Id", project.UI.ToString()))); project.IncludeWixExtension(WixExtension.UI); } if (project.EmbeddedUI != null) { string bynaryPath = project.EmbeddedUI.Name; if (project.EmbeddedUI is EmbeddedAssembly) { var asmBin = project.EmbeddedUI as EmbeddedAssembly; bynaryPath = asmBin.Name.PathChangeDirectory(project.OutDir.PathGetFullPath()) .PathChangeExtension(".CA.dll"); var refAsms = asmBin.RefAssemblies.Add(typeof(Session).Assembly.Location) .Concat(project.DefaultRefAssemblies) .Distinct() .ToArray(); PackageManagedAsm(asmBin.Name, bynaryPath, refAsms, project.OutDir, project.CustomActionConfig, null, true); } product.AddElement("UI") .Add(new XElement("EmbeddedUI", new XAttribute("Id", project.EmbeddedUI.Id), new XAttribute("SourceFile", bynaryPath))); product.Select("UIRef").Remove(); } if (!project.BannerImage.IsEmpty()) { product.Add(new XElement("WixVariable", new XAttribute("Id", "WixUIBannerBmp"), new XAttribute("Value", Utils.PathCombine(project.SourceBaseDir, project.BannerImage)))); } if (!project.BackgroundImage.IsEmpty()) { product.Add(new XElement("WixVariable", new XAttribute("Id", "WixUIDialogBmp"), new XAttribute("Value", Utils.PathCombine(project.SourceBaseDir, project.BackgroundImage)))); } if (!project.LicenceFile.IsEmpty()) { if (!AllowNonRtfLicense && !project.LicenceFile.EndsWith(".rtf", StringComparison.OrdinalIgnoreCase)) throw new ApplicationException("License file must have 'rtf' file extension. Specify 'Compiler.AllowNonRtfLicense=true' to overcome this constrain."); product.Add( new XElement("WixVariable", new XAttribute("Id", "WixUILicenseRtf"), new XAttribute("Value", Utils.PathCombine(project.SourceBaseDir, project.LicenceFile)), new XAttribute("xmlns", ""))); } PostProcessMsm(project, product); ProcessUpgradeStrategy(project, product); return doc; }
/// <summary> /// Processes the custom actions. /// </summary> /// <param name="wProject">The w project.</param> /// <param name="product">The product.</param> /// <exception cref="System.Exception">Step.PreviousAction is specified for the very first 'Custom Action'.\nThere cannot be any previous action as it is the very first one in the sequence.</exception> static void ProcessCustomActions(Project wProject, XElement product) { string lastActionName = null; foreach (Action wAction in wProject.Actions) { string step = wAction.Step.ToString(); if (wAction.When == When.After && wAction.Step == Step.PreviousAction) { if (lastActionName == null) throw new Exception("Step.PreviousAction is specified for the very first 'Custom Action'.\nThere cannot be any previous action as it is the very first one in the sequence."); step = lastActionName; } else if (wAction.When == When.After && wAction.Step == Step.PreviousActionOrInstallFinalize) step = lastActionName ?? Step.InstallFinalize.ToString(); else if (wAction.When == When.After && wAction.Step == Step.PreviousActionOrInstallInitialize) step = lastActionName ?? Step.InstallInitialize.ToString(); lastActionName = wAction.Id; List<XElement> sequences = new List<XElement>(); if (wAction.Sequence != Sequence.NotInSequence) { foreach (var item in wAction.Sequence.GetValues()) sequences.Add(product.SelectOrCreate(item)); } XAttribute sequenceNumberAttr = wAction.SequenceNumber.HasValue ? new XAttribute("Sequence", wAction.SequenceNumber.Value) : new XAttribute(wAction.When.ToString(), step); if (wAction is SetPropertyAction) { var wSetPropAction = (SetPropertyAction)wAction; var actionId = wSetPropAction.Id; lastActionName = actionId; //overwrite previously set standard CA name product.AddElement( new XElement("CustomAction", new XAttribute("Id", actionId), new XAttribute("Property", wSetPropAction.PropName), new XAttribute("Value", wSetPropAction.Value)) .SetAttribute("Return", wAction.Return) .SetAttribute("Impersonate", wAction.Impersonate) .SetAttribute("Execute", wAction.Execute) .AddAttributes(wAction.Attributes)); sequences.ForEach(sequence => sequence.Add(new XElement("Custom", wAction.Condition.ToString(), new XAttribute("Action", actionId), sequenceNumberAttr))); } else if (wAction is ScriptFileAction) { var wScriptAction = (ScriptFileAction)wAction; sequences.ForEach(sequence => sequence.Add(new XElement("Custom", wAction.Condition.ToString(), new XAttribute("Action", wAction.Id), sequenceNumberAttr))); product.Add(new XElement("Binary", new XAttribute("Id", wAction.Name.Expand() + "_File"), new XAttribute("SourceFile", Utils.PathCombine(wProject.SourceBaseDir, wScriptAction.ScriptFile)))); product.Add(new XElement("CustomAction", new XAttribute("Id", wAction.Id), new XAttribute("BinaryKey", wAction.Name.Expand() + "_File"), new XAttribute("VBScriptCall", wScriptAction.Procedure)) .SetAttribute("Return", wAction.Return) .SetAttribute("Impersonate", wAction.Impersonate) .SetAttribute("Execute", wAction.Execute) .AddAttributes(wAction.Attributes)); } else if (wAction is ScriptAction) { var wScriptAction = (ScriptAction)wAction; sequences.ForEach(sequence => sequence.Add(new XElement("Custom", wAction.Condition.ToString(), new XAttribute("Action", wAction.Id), sequenceNumberAttr))); product.Add(new XElement("CustomAction", new XCData(wScriptAction.Code), new XAttribute("Id", wAction.Id), new XAttribute("Script", "vbscript")) .SetAttribute("Return", wAction.Return) .SetAttribute("Impersonate", wAction.Impersonate) .SetAttribute("Execute", wAction.Execute) .AddAttributes(wAction.Attributes)); } else if (wAction is ManagedAction) { var wManagedAction = (ManagedAction)wAction; var asmFile = Utils.PathCombine(wProject.SourceBaseDir, wManagedAction.ActionAssembly); var packageFile = asmFile.PathChangeDirectory(wProject.OutDir.PathGetFullPath()) .PathChangeExtension(".CA.dll"); var existingBinary = product.Descendants("Binary") .Where(e => e.Attribute("SourceFile").Value == packageFile) .FirstOrDefault(); string bynaryKey; if (existingBinary == null) { PackageManagedAsm( asmFile, packageFile, wManagedAction.RefAssemblies.Concat(wProject.DefaultRefAssemblies).Distinct().ToArray(), wProject.OutDir, wProject.CustomActionConfig, wProject.Platform, false); bynaryKey = wAction.Name.Expand() + "_File"; product.Add(new XElement("Binary", new XAttribute("Id", bynaryKey), new XAttribute("SourceFile", packageFile))); } else { bynaryKey = existingBinary.Attribute("Id").Value; } if (wManagedAction.Execute == Execute.deferred && wManagedAction.UsesProperties != null) //map managed action properties { string mapping = wManagedAction.ExpandAllUsedProperties(); if (!mapping.IsEmpty()) { var setPropValuesId = "Set_" + wAction.Id + "_Props"; product.Add(new XElement("CustomAction", new XAttribute("Id", setPropValuesId), new XAttribute("Property", wAction.Id), new XAttribute("Value", mapping))); sequences.ForEach(sequence => sequence.Add( new XElement("Custom", new XAttribute("Action", setPropValuesId), wAction.SequenceNumber.HasValue ? new XAttribute("Sequence", wAction.SequenceNumber.Value) : new XAttribute("After", "InstallInitialize")))); } } sequences.ForEach(sequence => sequence.Add(new XElement("Custom", wAction.Condition.ToString(), new XAttribute("Action", wAction.Id), sequenceNumberAttr))); product.Add(new XElement("CustomAction", new XAttribute("Id", wAction.Id), new XAttribute("BinaryKey", bynaryKey), new XAttribute("DllEntry", wManagedAction.MethodName)) .SetAttribute("Return", wAction.Return) .SetAttribute("Impersonate", wAction.Impersonate) .SetAttribute("Execute", wAction.Execute) .AddAttributes(wAction.Attributes)); } else if (wAction is QtCmdLineAction) { var cmdLineAction = (QtCmdLineAction)wAction; var cmdLineActionId = wAction.Name.Expand(); var setCmdLineActionId = "Set_" + cmdLineActionId + "_CmdLine"; product.AddElement( new XElement("CustomAction", new XAttribute("Id", setCmdLineActionId), new XAttribute("Property", "QtExecCmdLine"), new XAttribute("Value", "\"" + cmdLineAction.AppPath.ExpandCommandPath() + "\" " + cmdLineAction.Args.ExpandCommandPath())) .AddAttributes(cmdLineAction.Attributes)); product.AddElement( new XElement("CustomAction", new XAttribute("Id", cmdLineActionId), new XAttribute("BinaryKey", "WixCA"), new XAttribute("DllEntry", "CAQuietExec")) .SetAttribute("Return", wAction.Return) .SetAttribute("Impersonate", wAction.Impersonate) .SetAttribute("Execute", wAction.Execute) .AddAttributes(wAction.Attributes)); lastActionName = cmdLineActionId; sequences.ForEach(sequence => sequence.Add( new XElement("Custom", wAction.Condition.ToString(), new XAttribute("Action", setCmdLineActionId), sequenceNumberAttr))); sequences.ForEach(sequence => sequence.Add( new XElement("Custom", wAction.Condition.ToString(), new XAttribute("Action", cmdLineActionId), new XAttribute("After", setCmdLineActionId)))); wProject.IncludeWixExtension(WixExtension.Util); } else if (wAction is InstalledFileAction) { var fileAction = (InstalledFileAction)wAction; sequences.ForEach(sequence => sequence.Add( new XElement("Custom", wAction.Condition.ToString(), new XAttribute("Action", wAction.Id), sequenceNumberAttr))); var actionElement = product.AddElement( new XElement("CustomAction", new XAttribute("Id", wAction.Id), new XAttribute("ExeCommand", fileAction.Args.ExpandCommandPath())) .SetAttribute("Return", wAction.Return) .SetAttribute("Impersonate", wAction.Impersonate) .SetAttribute("Execute", wAction.Execute) .AddAttributes(wAction.Attributes)); actionElement.Add(new XAttribute("FileKey", fileAction.Key)); } else if (wAction is BinaryFileAction) { var binaryAction = (BinaryFileAction)wAction; sequences.ForEach(sequence => sequence.Add( new XElement("Custom", wAction.Condition.ToString(), new XAttribute("Action", wAction.Id), sequenceNumberAttr))); var actionElement = product.AddElement( new XElement("CustomAction", new XAttribute("Id", wAction.Id), new XAttribute("ExeCommand", binaryAction.Args.ExpandCommandPath())) .SetAttribute("Return", wAction.Return) .SetAttribute("Impersonate", wAction.Impersonate) .SetAttribute("Execute", wAction.Execute) .AddAttributes(wAction.Attributes)); actionElement.Add(new XAttribute("BinaryKey", binaryAction.Key)); } else if (wAction is PathFileAction) { var fileAction = (PathFileAction)wAction; sequences.ForEach(sequence => sequence.Add( new XElement("Custom", fileAction.Condition.ToString(), new XAttribute("Action", wAction.Id), sequenceNumberAttr))); var actionElement = product.AddElement( new XElement("CustomAction", new XAttribute("Id", wAction.Id), new XAttribute("ExeCommand", "\"" + fileAction.AppPath.ExpandCommandPath() + "\" " + fileAction.Args.ExpandCommandPath())) .SetAttribute("Return", wAction.Return) .SetAttribute("Impersonate", wAction.Impersonate) .SetAttribute("Execute", wAction.Execute) .AddAttributes(fileAction.Attributes)); Dir installedDir = Array.Find(wProject.Dirs, (x) => x.Name == fileAction.WorkingDir); if (installedDir != null) actionElement.Add(new XAttribute("Directory", installedDir.Id)); else actionElement.Add(new XAttribute("Directory", fileAction.WorkingDir.Expand())); } } }
static void InsertIISElements(XElement dirItem, XElement component, IISVirtualDir[] wVDirs, Project project) { //http://ranjithk.com/2009/12/17/automating-web-deployment-using-windows-installer-xml-wix/ XNamespace ns = "http://schemas.microsoft.com/wix/IIsExtension"; string dirID = dirItem.Attribute("Id").Value; var xProduct = component.Parent("Product"); var uniqueWebSites = new List<WebSite>(); bool wasInserted = false; foreach (IISVirtualDir wVDir in wVDirs) { wasInserted = true; XElement xWebApp; var xVDir = component.AddElement(new XElement(ns + "WebVirtualDir", new XAttribute("Id", wVDir.Name.Expand()), new XAttribute("Alias", wVDir.Alias.IsEmpty() ? wVDir.Name : wVDir.Alias), new XAttribute("Directory", dirID), new XAttribute("WebSite", wVDir.WebSite.Name.Expand()), xWebApp = new XElement(ns + "WebApplication", new XAttribute("Id", wVDir.AppName.Expand() + "WebApplication"), new XAttribute("Name", wVDir.AppName)))); if (wVDir.AllowSessions.HasValue) xWebApp.Add(new XAttribute("AllowSessions", wVDir.AllowSessions.Value.ToYesNo())); if (wVDir.Buffer.HasValue) xWebApp.Add(new XAttribute("Buffer", wVDir.Buffer.Value.ToYesNo())); if (wVDir.ClientDebugging.HasValue) xWebApp.Add(new XAttribute("ClientDebugging", wVDir.ClientDebugging.Value.ToYesNo())); if (wVDir.DefaultScript.HasValue) xWebApp.Add(new XAttribute("DefaultScript", wVDir.DefaultScript.Value.ToString())); if (wVDir.Isolation.HasValue) xWebApp.Add(new XAttribute("Isolation", wVDir.Isolation.Value.ToString())); if (wVDir.ParentPaths.HasValue) xWebApp.Add(new XAttribute("ParentPaths", wVDir.ParentPaths.Value.ToYesNo())); if (wVDir.ScriptTimeout.HasValue) xWebApp.Add(new XAttribute("ScriptTimeout", wVDir.ScriptTimeout.Value)); if (wVDir.ServerDebugging.HasValue) xWebApp.Add(new XAttribute("ServerDebugging", wVDir.ServerDebugging.Value.ToYesNo())); if (wVDir.SessionTimeout.HasValue) xWebApp.Add(new XAttribute("SessionTimeout", wVDir.SessionTimeout.Value)); //do not create WebSite on IIS but install WebApp into existing if (!wVDir.WebSite.InstallWebSite) { if (!uniqueWebSites.Contains(wVDir.WebSite)) uniqueWebSites.Add(wVDir.WebSite); } else { InsertWebSite(wVDir.WebSite, dirID, component); } if (wVDir.WebAppPool != null) { var id = wVDir.Name.Expand() + "_AppPool"; xWebApp.Add(new XAttribute("WebAppPool", id)); var xAppPool = component.AddElement(new XElement(ns + "WebAppPool", new XAttribute("Id", id), new XAttribute("Name", wVDir.WebAppPool.Name))); xAppPool.AddAttributes(wVDir.WebAppPool.Attributes); } if (wVDir.WebDirProperties != null) { var propId = wVDir.Name.Expand() + "_WebDirProperties"; var xDirProp = xProduct.AddElement(new XElement(ns + "WebDirProperties", new XAttribute("Id", propId))); xDirProp.AddAttributes(wVDir.WebDirProperties.Attributes); xVDir.Add(new XAttribute("DirProperties", propId)); } } foreach (WebSite webSite in uniqueWebSites) { InsertWebSite(webSite, dirID, xProduct); } if (wasInserted) { project.IncludeWixExtension(WixExtension.IIs); } }
public static DriverInstaller Compile(this DriverInstaller driver, Project project, XElement component) { if (driver != null) { component.Add(driver.ToXml()); project.IncludeWixExtension(WixExtension.Difx); project.LibFiles.Add(System.IO.Path.Combine(Compiler.WixLocation, "difxapp_{0}.wixlib".FormatInline(driver.Architecture))); } return driver; }