示例#1
0
        /// <summary>
        /// Adds a SetProperty CA for a Directory.
        /// </summary>
        /// <param name="propertyId">The Id of the Property to set.</param>
        /// <param name="value">The value to set the Property to.</param>
        private void AddSetPropertyCustomAction(string propertyId, string value)
        {
            // Add the action
            Wix.CustomAction customAction = new Wix.CustomAction();
            customAction.Id       = propertyId;
            customAction.Property = propertyId;
            customAction.Value    = value;
            this.fragment.AddChild(customAction);

            // Schedule the action
            Wix.InstallExecuteSequence installExecuteSequence = new Wix.InstallExecuteSequence();
            Wix.Custom custom = new Wix.Custom();
            custom.Action = customAction.Id;
            custom.Before = "CostInitialize";
            installExecuteSequence.AddChild(custom);
            this.fragment.AddChild(installExecuteSequence);
        }
示例#2
0
        /// <summary>
        /// Decompile the CustomAction table.
        /// </summary>
        /// <param name="table">The table to decompile.</param>
        private void DecompileCustomActionTable(Table table)
        {
            foreach (Row row in table.Rows)
            {
                Wix.CustomAction customAction = new Wix.CustomAction();

                customAction.Id = Convert.ToString(row[0]);

                int type = Convert.ToInt32(row[1]);

                if (MsiInterop.MsidbCustomActionTypeHideTarget == (type & MsiInterop.MsidbCustomActionTypeHideTarget))
                {
                    customAction.HideTarget = Wix.YesNoType.yes;
                }

                if (MsiInterop.MsidbCustomActionTypeNoImpersonate == (type & MsiInterop.MsidbCustomActionTypeNoImpersonate))
                {
                    customAction.Impersonate = Wix.YesNoType.no;
                }

                if (MsiInterop.MsidbCustomActionTypeTSAware == (type & MsiInterop.MsidbCustomActionTypeTSAware))
                {
                    customAction.TerminalServerAware = Wix.YesNoType.yes;
                }

                if (MsiInterop.MsidbCustomActionType64BitScript == (type & MsiInterop.MsidbCustomActionType64BitScript))
                {
                    customAction.Win64 = Wix.YesNoType.yes;
                }

                switch (type & MsiInterop.MsidbCustomActionTypeExecuteBits)
                {
                    case 0:
                        // this is the default value
                        break;
                    case MsiInterop.MsidbCustomActionTypeFirstSequence:
                        customAction.Execute = Wix.CustomAction.ExecuteType.firstSequence;
                        break;
                    case MsiInterop.MsidbCustomActionTypeOncePerProcess:
                        customAction.Execute = Wix.CustomAction.ExecuteType.oncePerProcess;
                        break;
                    case MsiInterop.MsidbCustomActionTypeClientRepeat:
                        customAction.Execute = Wix.CustomAction.ExecuteType.secondSequence;
                        break;
                    case MsiInterop.MsidbCustomActionTypeInScript:
                        customAction.Execute = Wix.CustomAction.ExecuteType.deferred;
                        break;
                    case MsiInterop.MsidbCustomActionTypeInScript + MsiInterop.MsidbCustomActionTypeRollback:
                        customAction.Execute = Wix.CustomAction.ExecuteType.rollback;
                        break;
                    case MsiInterop.MsidbCustomActionTypeInScript + MsiInterop.MsidbCustomActionTypeCommit:
                        customAction.Execute = Wix.CustomAction.ExecuteType.commit;
                        break;
                    default:
                        this.core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[1].Column.Name, row[1]));
                        break;
                }

                switch (type & MsiInterop.MsidbCustomActionTypeReturnBits)
                {
                    case 0:
                        // this is the default value
                        break;
                    case MsiInterop.MsidbCustomActionTypeContinue:
                        customAction.Return = Wix.CustomAction.ReturnType.ignore;
                        break;
                    case MsiInterop.MsidbCustomActionTypeAsync:
                        customAction.Return = Wix.CustomAction.ReturnType.asyncWait;
                        break;
                    case MsiInterop.MsidbCustomActionTypeAsync + MsiInterop.MsidbCustomActionTypeContinue:
                        customAction.Return = Wix.CustomAction.ReturnType.asyncNoWait;
                        break;
                    default:
                        this.core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[1].Column.Name, row[1]));
                        break;
                }

                int source = type & MsiInterop.MsidbCustomActionTypeSourceBits;
                switch (source)
                {
                    case MsiInterop.MsidbCustomActionTypeBinaryData:
                        customAction.BinaryKey = Convert.ToString(row[2]);
                        break;
                    case MsiInterop.MsidbCustomActionTypeSourceFile:
                        if (null != row[2])
                        {
                            customAction.FileKey = Convert.ToString(row[2]);
                        }
                        break;
                    case MsiInterop.MsidbCustomActionTypeDirectory:
                        if (null != row[2])
                        {
                            customAction.Directory = Convert.ToString(row[2]);
                        }
                        break;
                    case MsiInterop.MsidbCustomActionTypeProperty:
                        customAction.Property = Convert.ToString(row[2]);
                        break;
                    default:
                        this.core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[1].Column.Name, row[1]));
                        break;
                }

                switch (type & MsiInterop.MsidbCustomActionTypeTargetBits)
                {
                    case MsiInterop.MsidbCustomActionTypeDll:
                        customAction.DllEntry = Convert.ToString(row[3]);
                        break;
                    case MsiInterop.MsidbCustomActionTypeExe:
                        customAction.ExeCommand = Convert.ToString(row[3]);
                        break;
                    case MsiInterop.MsidbCustomActionTypeTextData:
                        if (MsiInterop.MsidbCustomActionTypeSourceFile == source)
                        {
                            customAction.Error = Convert.ToString(row[3]);
                        }
                        else
                        {
                            customAction.Value = Convert.ToString(row[3]);
                        }
                        break;
                    case MsiInterop.MsidbCustomActionTypeJScript:
                        if (MsiInterop.MsidbCustomActionTypeDirectory == source)
                        {
                            customAction.Script = Wix.CustomAction.ScriptType.jscript;
                            customAction.Content = Convert.ToString(row[3]);
                        }
                        else
                        {
                            customAction.JScriptCall = Convert.ToString(row[3]);
                        }
                        break;
                    case MsiInterop.MsidbCustomActionTypeVBScript:
                        if (MsiInterop.MsidbCustomActionTypeDirectory == source)
                        {
                            customAction.Script = Wix.CustomAction.ScriptType.vbscript;
                            customAction.Content = Convert.ToString(row[3]);
                        }
                        else
                        {
                            customAction.VBScriptCall = Convert.ToString(row[3]);
                        }
                        break;
                    case MsiInterop.MsidbCustomActionTypeInstall:
                        this.core.OnMessage(WixWarnings.NestedInstall(row.SourceLineNumbers, table.Name, row.Fields[1].Column.Name, row[1]));
                        continue;
                    default:
                        this.core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[1].Column.Name, row[1]));
                        break;
                }

                int extype = 4 < row.Fields.Length && null != row[4] ? Convert.ToInt32(row[4]) : 0;
                if (MsiInterop.MsidbCustomActionTypePatchUninstall == (extype & MsiInterop.MsidbCustomActionTypePatchUninstall))
                {
                    customAction.PatchUninstall = Wix.YesNoType.yes;
                }

                this.core.RootElement.AddChild(customAction);
                this.core.IndexElement(row, customAction);
            }
        }
示例#3
0
        /// <summary>
        /// Converts a Module to a ComponentGroup and adds all of its relevant elements to the main fragment.
        /// </summary>
        /// <param name="wix">The output object representing an unbound merge module.</param>
        private void ConvertModule(Wix.Wix wix)
        {
            Wix.Product product = Melter.GetProduct(wix);

            List <string> customActionsRemoved = new List <string>();
            Dictionary <Wix.Custom, Wix.InstallExecuteSequence> customsToRemove = new Dictionary <Wix.Custom, Wix.InstallExecuteSequence>();

            foreach (Wix.ISchemaElement child in product.Children)
            {
                Wix.Directory childDir = child as Wix.Directory;
                if (null != childDir)
                {
                    bool isTargetDir = this.WalkDirectory(childDir);
                    if (isTargetDir)
                    {
                        continue;
                    }
                }
                else
                {
                    Wix.Dependency childDep = child as Wix.Dependency;
                    if (null != childDep)
                    {
                        this.AddPropertyRef(childDep.RequiredId);
                        continue;
                    }
                    else if (child is Wix.Package)
                    {
                        continue;
                    }
                    else if (child is Wix.CustomAction)
                    {
                        Wix.CustomAction customAction = child as Wix.CustomAction;
                        string           directoryId;
                        if (StartsWithStandardDirectoryId(customAction.Id, out directoryId) && customAction.Property == customAction.Id)
                        {
                            customActionsRemoved.Add(customAction.Id);
                            continue;
                        }
                    }
                    else if (child is Wix.InstallExecuteSequence)
                    {
                        Wix.InstallExecuteSequence installExecuteSequence = child as Wix.InstallExecuteSequence;

                        foreach (Wix.ISchemaElement sequenceChild in installExecuteSequence.Children)
                        {
                            Wix.Custom custom = sequenceChild as Wix.Custom;
                            string     directoryId;
                            if (custom != null && StartsWithStandardDirectoryId(custom.Action, out directoryId))
                            {
                                customsToRemove.Add(custom, installExecuteSequence);
                            }
                        }
                    }
                }

                this.fragment.AddChild(child);
            }

            // For any customaction that we removed, also remove the scheduling of that action.
            foreach (Wix.Custom custom in customsToRemove.Keys)
            {
                if (customActionsRemoved.Contains(custom.Action))
                {
                    ((Wix.InstallExecuteSequence)customsToRemove[custom]).RemoveChild(custom);
                }
            }

            AddProperty(this.moduleId, this.id);

            wix.RemoveChild(product);
            wix.AddChild(this.fragment);

            this.fragment.AddChild(this.componentGroup);
            this.fragment.AddChild(this.primaryDirectoryRef);
        }
示例#4
0
文件: Melter.cs 项目: Jeremiahf/wix3
        /// <summary>
        /// Adds a SetProperty CA for a Directory.
        /// </summary>
        /// <param name="propertyId">The Id of the Property to set.</param>
        /// <param name="value">The value to set the Property to.</param>
        private void AddSetPropertyCustomAction(string propertyId, string value)
        {
            // Add the action
            Wix.CustomAction customAction = new Wix.CustomAction();
            customAction.Id = propertyId;
            customAction.Property = propertyId;
            customAction.Value = value;
            this.fragment.AddChild(customAction);

            // Schedule the action
            Wix.InstallExecuteSequence installExecuteSequence = new Wix.InstallExecuteSequence();
            Wix.Custom custom = new Wix.Custom();
            custom.Action = customAction.Id;
            custom.Before = "CostInitialize";
            installExecuteSequence.AddChild(custom);
            this.fragment.AddChild(installExecuteSequence);
        }