Ejemplo n.º 1
0
 internal void RemoveProductCode(Guid productCode)
 {
     TaskLogger.LogEnter();
     base.SetLogging();
     try
     {
         MsiUtility.PushExternalUI(base.UIHandler, (InstallLogMode)10115);
         try
         {
             string text = productCode.ToString("B").ToUpper(CultureInfo.InvariantCulture);
             base.WriteVerbose(Strings.RemovingPackageByProductCode(productCode));
             uint num = MsiNativeMethods.ConfigureProduct(text, InstallLevel.Default, InstallState.Default, base.PropertyValues);
             if (num != 0U)
             {
                 Win32Exception ex = new Win32Exception((int)num);
                 if (num == 3010U)
                 {
                     if (this.WarnOnRebootRequests)
                     {
                         TaskException ex2 = new TaskException(Strings.MsiRebootRequiredToFinish(text), ex);
                         TaskLogger.SendWatsonReport(ex2);
                         base.WriteWarning(ex2.Message);
                     }
                     else if (UninstallMsi.rebootRequiredException == null)
                     {
                         UninstallMsi.rebootRequiredException = new TaskException(Strings.MsiRebootRequiredToContinue(text), ex);
                     }
                 }
                 else if (string.IsNullOrEmpty(base.LastMsiError))
                 {
                     base.WriteError(new TaskException(Strings.MsiCouldNotRemoveProduct(productCode, ex.Message, (int)num), ex), ErrorCategory.InvalidOperation, null);
                 }
                 else
                 {
                     base.WriteError(new TaskException(Strings.MsiCouldNotRemoveProductDetailed(productCode, ex.Message, (int)num, base.LastMsiError), ex), ErrorCategory.InvalidOperation, null);
                 }
             }
         }
         finally
         {
             MsiUtility.PopExternalUI();
         }
     }
     catch (ArgumentOutOfRangeException exception)
     {
         base.WriteError(exception, ErrorCategory.InvalidArgument, 0);
     }
     TaskLogger.LogExit();
 }
Ejemplo n.º 2
0
 internal void InstallPackageFile(string packagePath)
 {
     TaskLogger.LogEnter();
     try
     {
         Guid productCode = MsiUtility.GetProductCode(this.PackagePath);
         base.SetLogging();
         MsiUtility.PushExternalUI(base.UIHandler, (InstallLogMode)10115);
         try
         {
             base.WriteVerbose(Strings.InstallingPackage(packagePath));
             List <MsiNativeMethods.PatchSequenceInfo> list = new List <MsiNativeMethods.PatchSequenceInfo>();
             uint num;
             if (this.UpdatesDir != null)
             {
                 try
                 {
                     string[] files = Directory.GetFiles(this.UpdatesDir.PathName, "*.msp");
                     foreach (string patchData in files)
                     {
                         MsiNativeMethods.PatchSequenceInfo item = new MsiNativeMethods.PatchSequenceInfo
                         {
                             patchData     = patchData,
                             patchDataType = PatchDataType.PatchFile,
                             order         = -1,
                             status        = 0U
                         };
                         list.Add(item);
                         base.WriteVerbose(Strings.PatchFileFound(item.patchData));
                     }
                 }
                 catch (DirectoryNotFoundException)
                 {
                     base.WriteVerbose(Strings.UpdatesDirectoryNotFound(this.UpdatesDir.PathName));
                 }
                 catch (IOException exception)
                 {
                     base.WriteError(exception, ErrorCategory.InvalidOperation, null);
                 }
                 if (list.Count > 0)
                 {
                     MsiNativeMethods.PatchSequenceInfo[] array2 = list.ToArray();
                     num = MsiNativeMethods.DetermineApplicablePatches(this.PackagePath, array2.Length, array2);
                     if (num != 0U)
                     {
                         base.WriteError(new TaskException(Strings.FailedToSortPatches(num)), ErrorCategory.InvalidOperation, null);
                     }
                     else
                     {
                         base.WriteVerbose(Strings.SortedAvailablePatches);
                         List <MsiNativeMethods.PatchSequenceInfo> list2 = new List <MsiNativeMethods.PatchSequenceInfo>();
                         foreach (MsiNativeMethods.PatchSequenceInfo item2 in array2)
                         {
                             base.WriteVerbose(Strings.PrintPatchOrderInfo(item2.patchData, item2.order, item2.status));
                             if (item2.order >= 0)
                             {
                                 list2.Add(item2);
                             }
                         }
                         if (list2.Count > 0)
                         {
                             list2.Sort(new Comparison <MsiNativeMethods.PatchSequenceInfo>(MsiNativeMethods.ComparePatchSequence));
                             StringBuilder stringBuilder = new StringBuilder();
                             foreach (MsiNativeMethods.PatchSequenceInfo patchSequenceInfo in list2)
                             {
                                 base.WriteVerbose(Strings.ValidPatch(patchSequenceInfo.patchData, patchSequenceInfo.order));
                                 stringBuilder.Append(patchSequenceInfo.patchData);
                                 stringBuilder.Append(";");
                             }
                             base.WriteVerbose(Strings.PatchAttributeValue(stringBuilder.ToString()));
                             base.PropertyValues = string.Format("PATCH=\"{0}\" {1}", stringBuilder.ToString(), base.PropertyValues);
                         }
                     }
                 }
             }
             else
             {
                 base.WriteVerbose(Strings.NoUpdatesDirectorySpecified);
             }
             if (this.newProduct)
             {
                 base.WriteVerbose(Strings.NewProductInstallation(packagePath, base.PropertyValues));
                 num = MsiNativeMethods.InstallProduct(packagePath, base.PropertyValues);
             }
             else
             {
                 string productCodeString = productCode.ToString("B").ToUpper(CultureInfo.InvariantCulture);
                 base.WriteVerbose(Strings.ExistingProductConfiguration(productCodeString, base.PropertyValues));
                 num = MsiNativeMethods.ConfigureProduct(productCodeString, InstallLevel.Default, InstallState.Default, base.PropertyValues);
             }
             if (num != 0U)
             {
                 Win32Exception ex = new Win32Exception((int)num);
                 if (num == 3010U)
                 {
                     throw new TaskException(Strings.MsiRebootRequiredToContinue(packagePath), ex);
                 }
                 if (string.IsNullOrEmpty(base.LastMsiError))
                 {
                     base.WriteError(new TaskException(Strings.MsiInstallFailed(packagePath, ex.Message, (int)num), ex), ErrorCategory.InvalidOperation, null);
                 }
                 else
                 {
                     base.WriteError(new TaskException(Strings.MsiInstallFailedDetailed(packagePath, ex.Message, (int)num, base.LastMsiError), ex), ErrorCategory.InvalidOperation, null);
                 }
             }
         }
         finally
         {
             MsiUtility.PopExternalUI();
         }
     }
     catch (ArgumentOutOfRangeException exception2)
     {
         base.WriteError(exception2, ErrorCategory.InvalidArgument, null);
     }
     catch (TaskException exception3)
     {
         base.WriteError(exception3, ErrorCategory.InvalidOperation, null);
     }
     TaskLogger.LogExit();
 }