Пример #1
0
        /// <summary>
        /// Enables the full UI.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="displayIconPath">The location of the app icon in the ARP.</param>
        /// <param name="extraParameters">Extra parameters for msiexec</param>
        public static void EnableUninstallFullUI(this Project project, string displayIconPath, string extraParameters = "")
        {
            if (displayIconPath != null)
            {
                // Add the DisplayIcon key to the Uninstall section
                project.AddRegValues(
                    new RegValue(new Id("WixSharp_RegValue_DisplayIcon"),
                                 RegistryHive.LocalMachine,
                                 @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\[ProductCode]",
                                 "DisplayIcon",
                                 displayIconPath));
            }

            project.AddAction(new ElevatedManagedAction(
                                  new Id(nameof(WixSharp_EnableUninstallFullUI_Action)),
                                  WixSharp_EnableUninstallFullUI_Action,
                                  typeof(UninstallFullUI).Assembly.Location,
                                  Return.ignore,
                                  When.Before,
                                  Step.InstallFinalize,
                                  Condition.NOT_Installed)
            {
                UsesProperties =
                    $"MSIEXEC_EXTRA_PARAMETERS={extraParameters ?? ""}",
            });

            project.WixSourceGenerated += doc =>
            {
                /*
                 * <Component Id="...
                 *    <RegistryKey Root="...
                 *        <RegistryValue Id="WixSharp_RegValue_DisplayIcon..."
                 */

                if (displayIconPath == null)
                {
                    return;
                }

                var comp = doc.FindAll("RegistryValue")
                           .First(x => x.HasAttribute("Id", "WixSharp_RegValue_DisplayIcon"))
                           .Parent
                           .Parent;

                var compId = comp.Attribute("Id").Value;

                var features = doc.FindAll("Feature")
                               .Where(x => !x.FindAll("ComponentRef")
                                      .Any(y => y.HasAttribute("Id", compId))).ToArray();

                features.ForEach(f => f.AddElement("ComponentRef", $"Id={compId}"));
            };
        }
Пример #2
0
        /// <summary>
        /// Enables the full UI.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="displayIconPath">The location of the app icon in the ARP.</param>
        public static void EnableUninstallFullUI(this Project project, string displayIconPath)
        {
            if (displayIconPath != null)
            {
                // Add the DisplayIcon key to the Uninstall section
                project.AddRegValues(
                    new RegValue(new Id("WixSharp_RegValue_DisplayIcon"),
                                 RegistryHive.LocalMachine,
                                 @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\[ProductCode]",
                                 "DisplayIcon",
                                 displayIconPath));
            }

            project.AddAction(new ElevatedManagedAction(
                                  new Id(nameof(WixSharp_EnableUninstallFullUI_Action)),
                                  WixSharp_EnableUninstallFullUI_Action,
                                  typeof(UninstallFullUI).Assembly.Location,
                                  Return.ignore,
                                  When.Before,
                                  Step.InstallFinalize,
                                  Condition.NOT_Installed));
        }