public virtual bool GetDiff(string diffInput1, string diffInput2, string[] options, TextWriter diffOutput, string linePrefix, IDiffEngineFactory diffFactory) { bool difference = false; Database db1 = new Database(diffInput1, DatabaseOpenMode.ReadOnly); Database db2 = new Database(diffInput2, DatabaseOpenMode.ReadOnly); if(GetSummaryInfoDiff(db1, db2, options, diffOutput, linePrefix, diffFactory)) difference = true; if(GetDatabaseDiff(db1, db2, options, diffOutput, linePrefix, diffFactory)) difference = true; if(GetStreamsDiff(db1, db2, options, diffOutput, linePrefix, diffFactory)) difference = true; db1.Close(); db2.Close(); return difference; }
public override bool GetDiff(string diffInput1, string diffInput2, string[] options, TextWriter diffOutput, string linePrefix, IDiffEngineFactory diffFactory) { bool difference = false; InstallPackage db1, db2; if(IsMspPatch(diffInput1)) { string patchTargetDbFile = GetPatchTargetOption(options); if(patchTargetDbFile == null) patchTargetDbFile = diffInput2; string tempPatchedDbFile = Path.GetTempFileName(); File.Copy(patchTargetDbFile, tempPatchedDbFile, true); File.SetAttributes(tempPatchedDbFile, File.GetAttributes(tempPatchedDbFile) & ~System.IO.FileAttributes.ReadOnly); db1 = new InstallPackage(tempPatchedDbFile, DatabaseOpenMode.Direct); db1.ApplyPatch(new PatchPackage(diffInput1), null); db1.Commit(); } else { db1 = new InstallPackage(diffInput1, DatabaseOpenMode.ReadOnly); } if(IsMspPatch(diffInput2)) { string patchTargetDbFile = GetPatchTargetOption(options); if(patchTargetDbFile == null) patchTargetDbFile = diffInput1; string tempPatchedDbFile = Path.GetTempFileName(); File.Copy(patchTargetDbFile, tempPatchedDbFile, true); File.SetAttributes(tempPatchedDbFile, File.GetAttributes(tempPatchedDbFile) & ~System.IO.FileAttributes.ReadOnly); db2 = new InstallPackage(tempPatchedDbFile, DatabaseOpenMode.Direct); db2.ApplyPatch(new PatchPackage(diffInput2), null); db2.Commit(); } else { db2 = new InstallPackage(diffInput2, DatabaseOpenMode.ReadOnly); } if(GetSummaryInfoDiff(db1, db2, options, diffOutput, linePrefix, diffFactory)) difference = true; if(GetDatabaseDiff(db1, db2, options, diffOutput, linePrefix, diffFactory)) difference = true; if(GetStreamsDiff(db1, db2, options, diffOutput, linePrefix, diffFactory)) difference = true; db1.Close(); db2.Close(); try { if(IsMspPatch(diffInput1)) File.Delete(db1.FilePath); if(IsMspPatch(diffInput1)) File.Delete(db2.FilePath); } catch(IOException) { #if DEBUG Console.WriteLine("Could not delete temporary files {0} and {1}", db1.FilePath, db2.FilePath); #endif } if(IsMspPatch(diffInput1) && IsMspPatch(diffInput2)) { Database dbp1 = new Database(diffInput1, DatabaseOpenMode.ReadOnly); Database dbp2 = new Database(diffInput2, DatabaseOpenMode.ReadOnly); if(GetStreamsDiff(dbp1, dbp2, options, diffOutput, linePrefix, diffFactory)) difference = true; dbp1.Close(); dbp2.Close(); } return difference; }
/// <summary> /// adds or updates a property in an msi file. /// </summary> /// <param name="msiFile">full path to the msi file to update</param> /// <param name="propertyName">name of property to add or update</param> /// <param name="propertyValue">value of property</param> public static void SetPropertyInMsi(string msiFile, string propertyName, string propertyValue) { Database db = new Database(msiFile, DatabaseOpenMode.Direct); string sql; try { // GetProperty will throw if the propertyName does not exist in the property table GetProperty(db, propertyName); sql = string.Format("UPDATE `Property` SET `Value` = '{0}' WHERE `Property` = '{1}'", propertyValue, propertyName); } catch { sql = string.Format("INSERT INTO `Property` (`Property`, `Value`) VALUES ('{0}', '{1}')", propertyName, propertyValue); } db.Execute(sql); db.Commit(); db.Close(); }
public static string GetProperty(string msiPath, string property) { string propertyValue = null; if (!String.IsNullOrEmpty(msiPath)) { msiPath = System.Environment.ExpandEnvironmentVariables(msiPath); Database db = new Database(msiPath); propertyValue = MsiUtils.GetProperty(db, property); db.Close(); // be sure to close the db or future attempts to open it will fail (i.e. to install/uninstall it) } return propertyValue; }