/// <summary> /// Applies any applicable transforms from <see cref="Patch"/> and <see cref="Transform"/> to the given package. /// </summary> /// <param name="db">The <see cref="InstallPackage"/> database to which applicable transforms are applied.</param> protected void ApplyTransforms(InstallPackage db) { // Apply transforms first since they likely apply to the unpatched product. if (0 < this.Transform.Count()) { this.Transform = this.ResolveFiles(this.Transform).ToArray(); foreach (string path in this.Transform) { try { db.ApplyTransform(path, PatchApplicator.IgnoreErrors); db.ApplyTransform(path, PatchApplicator.IgnoreErrors | TransformErrors.ViewTransform); } catch (InstallerException ex) { using (var pse = new PSInstallerException(ex)) { if (null != pse.ErrorRecord) { base.WriteError(pse.ErrorRecord); } } } } db.Commit(); } // Apply applicable patch transforms. if (0 < this.Patch.Count()) { this.Patch = this.ResolveFiles(this.Patch).ToArray(); var applicator = new PatchApplicator(db); foreach (string path in this.Patch) { applicator.Add(path); } applicator.InapplicablePatch += (source, args) => { var message = string.Format(CultureInfo.CurrentCulture, Resources.Error_InapplicablePatch, args.Patch, args.Product); base.WriteVerbose(message); }; // The applicator will commit the changes. applicator.Apply(); } }