Ejemplo n.º 1
0
        public static bool IsInstalled(string packagePath)
        {
            TaskLogger.LogEnter();
            if (packagePath == null || packagePath == string.Empty)
            {
                throw new ArgumentNullException("packagePath", Strings.ExceptionProductInfoRequired);
            }
            Guid productCode = MsiUtility.GetProductCode(packagePath);
            bool result      = MsiUtility.IsInstalled(productCode);

            TaskLogger.LogExit();
            return(result);
        }
Ejemplo n.º 2
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     if (this.ProductCode == Guid.Empty && string.IsNullOrEmpty(this.PackagePath))
     {
         base.ThrowTerminatingError(new ArgumentNullException("ProductInfo", Strings.ExceptionProductInfoRequired), ErrorCategory.InvalidArgument, null);
     }
     else
     {
         try
         {
             if (!string.IsNullOrEmpty(this.PackagePath) && MsiUtility.IsInstalled(this.PackagePath))
             {
                 this.isInstalled = true;
             }
             else if (this.ProductCode != Guid.Empty && MsiUtility.IsInstalled(this.ProductCode))
             {
                 this.isInstalled = true;
             }
         }
         catch (ArgumentNullException exception)
         {
             base.WriteError(exception, ErrorCategory.InvalidArgument, null);
         }
         catch (ArgumentOutOfRangeException exception2)
         {
             base.WriteError(exception2, ErrorCategory.InvalidArgument, null);
         }
         catch (TaskException exception3)
         {
             base.WriteError(exception3, ErrorCategory.InvalidOperation, null);
         }
     }
     if (this.isInstalled)
     {
         if (base.Features != null && base.Features.Length != 0)
         {
             List <string> list = new List <string>(base.Features);
             bool          flag = string.Equals("ExchangeServer.MSI", Path.GetFileName(this.PackagePath), StringComparison.OrdinalIgnoreCase);
             if (flag)
             {
                 bool flag2 = false;
                 bool flag3 = false;
                 foreach (string b in list)
                 {
                     if (string.Equals("Gateway", b, StringComparison.OrdinalIgnoreCase))
                     {
                         flag2 = true;
                     }
                     else if (string.Equals("AdminTools", b, StringComparison.OrdinalIgnoreCase))
                     {
                         flag3 = true;
                     }
                 }
                 if (flag2 && !flag3)
                 {
                     base.PropertyValues = string.Format("{0} ADDLOCAL={1}", base.PropertyValues, "AdminToolsNonGateway");
                 }
                 if (flag2 && flag3)
                 {
                     list.Add("AdminToolsNonGateway");
                 }
             }
             base.PropertyValues = string.Format("{0} REMOVE={1}", base.PropertyValues, string.Join(",", base.Features));
         }
         else
         {
             base.PropertyValues = string.Format("{0} REMOVE=ALL", base.PropertyValues);
         }
         if (base.ParameterSetName == "PackagePath")
         {
             string fullPath = Path.GetFullPath(this.PackagePath);
             base.WriteVerbose(Strings.MsiFullPackagePath(this.PackagePath, fullPath));
             this.PackagePath = fullPath;
             try
             {
                 this.ProductCode = MsiUtility.GetProductCode(this.PackagePath);
             }
             catch (ArgumentOutOfRangeException exception4)
             {
                 base.WriteError(exception4, ErrorCategory.InvalidArgument, null);
             }
             catch (TaskException exception5)
             {
                 base.WriteError(exception5, ErrorCategory.InvalidOperation, null);
             }
         }
         if (!base.Fields.IsChanged("LogFile") && this.PackagePath != null && this.PackagePath != string.Empty)
         {
             base.LogFile = Path.Combine(ConfigurationContext.Setup.SetupLoggingPath, Path.ChangeExtension(Path.GetFileName(this.PackagePath), ".msilog"));
         }
     }
     TaskLogger.LogExit();
 }
Ejemplo n.º 3
0
 protected override void InternalBeginProcessing()
 {
     TaskLogger.LogEnter();
     base.InternalBeginProcessing();
     try
     {
         this.newProduct = !MsiUtility.IsInstalled(this.PackagePath);
     }
     catch (ArgumentNullException exception)
     {
         base.WriteError(exception, ErrorCategory.InvalidArgument, null);
     }
     catch (ArgumentOutOfRangeException exception2)
     {
         base.WriteError(exception2, ErrorCategory.InvalidArgument, null);
     }
     catch (TaskException exception3)
     {
         base.WriteError(exception3, ErrorCategory.InvalidOperation, null);
     }
     if (!this.NoActionIfInstalled || this.newProduct)
     {
         if (!this.Reinstall)
         {
             if (this.newProduct && this.TargetDirectory != null && this.TargetDirectory.ToString() != string.Empty)
             {
                 base.PropertyValues = string.Format("{0} TARGETDIR=\"{1}\"", base.PropertyValues, this.TargetDirectory);
             }
             if (base.Features != null && base.Features.Length != 0)
             {
                 List <string> list = new List <string>(base.Features);
                 bool          flag = string.Equals("ExchangeServer.MSI", Path.GetFileName(this.PackagePath), StringComparison.OrdinalIgnoreCase);
                 if (flag)
                 {
                     bool flag2 = false;
                     bool flag3 = false;
                     foreach (string b in list)
                     {
                         if (string.Equals("Gateway", b, StringComparison.OrdinalIgnoreCase))
                         {
                             flag2 = true;
                         }
                         else if (string.Equals("AdminTools", b, StringComparison.OrdinalIgnoreCase))
                         {
                             flag3 = true;
                         }
                     }
                     if (flag2 && !flag3)
                     {
                         base.PropertyValues = string.Format("{0} REMOVE={1}", base.PropertyValues, "AdminToolsNonGateway");
                     }
                     if (!flag2 && flag3)
                     {
                         list.Add("AdminToolsNonGateway");
                     }
                 }
                 base.PropertyValues = string.Format("{0} ADDLOCAL={1}", base.PropertyValues, string.Join(",", list.ToArray()));
             }
         }
         else
         {
             base.PropertyValues = string.Format("{0} REINSTALL=ALL REINSTALLMODE={1}", base.PropertyValues, this.ReinstallMode);
         }
         if (!base.Fields.IsChanged("LogFile"))
         {
             base.LogFile = Path.Combine(ConfigurationContext.Setup.SetupLoggingPath, Path.ChangeExtension(Path.GetFileName(this.PackagePath), ".msilog"));
         }
         string fullPath = Path.GetFullPath(this.PackagePath);
         base.WriteVerbose(Strings.MsiFullPackagePath(this.PackagePath, fullPath));
         this.PackagePath = fullPath;
     }
     else
     {
         base.WriteVerbose(Strings.MsiPackageAlreadyInstalled(this.PackagePath));
     }
     TaskLogger.LogExit();
 }