diff options
| author | Rob Mensching <rob@firegiant.com> | 2020-05-30 14:53:05 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2020-05-30 15:07:21 -0700 |
| commit | d529525a1e331f3ef9ec2707791c99bd78fdd82f (patch) | |
| tree | 1d9fe1f0c0ee9850371c916802eb03ec9dc37a87 /src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs | |
| parent | 9c54d2fce80983bbee5f0f113b5aa30f22bc8a23 (diff) | |
| download | wix-d529525a1e331f3ef9ec2707791c99bd78fdd82f.tar.gz wix-d529525a1e331f3ef9ec2707791c99bd78fdd82f.tar.bz2 wix-d529525a1e331f3ef9ec2707791c99bd78fdd82f.zip | |
Basic patching support
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs | 66 |
1 files changed, 25 insertions, 41 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs index 214bf617..a16bafd7 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs | |||
| @@ -147,7 +147,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 147 | { | 147 | { |
| 148 | foreach (MediaRow transformMediaRow in transformMediaTable.Rows) | 148 | foreach (MediaRow transformMediaRow in transformMediaTable.Rows) |
| 149 | { | 149 | { |
| 150 | if (mediaTuple.LastSequence < transformMediaRow.LastSequence) | 150 | if (!mediaTuple.LastSequence.HasValue || mediaTuple.LastSequence < transformMediaRow.LastSequence) |
| 151 | { | 151 | { |
| 152 | // The Binder will pre-increment the sequence. | 152 | // The Binder will pre-increment the sequence. |
| 153 | mediaTuple.LastSequence = transformMediaRow.LastSequence; | 153 | mediaTuple.LastSequence = transformMediaRow.LastSequence; |
| @@ -156,14 +156,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | // Use the Media/@DiskId if greater than the last sequence for backward compatibility. | 158 | // Use the Media/@DiskId if greater than the last sequence for backward compatibility. |
| 159 | if (mediaTuple.LastSequence < mediaTuple.DiskId) | 159 | if (!mediaTuple.LastSequence.HasValue || mediaTuple.LastSequence < mediaTuple.DiskId) |
| 160 | { | 160 | { |
| 161 | mediaTuple.LastSequence = mediaTuple.DiskId; | 161 | mediaTuple.LastSequence = mediaTuple.DiskId; |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | // Ignore media table in the transform. | 164 | // Ignore media table in the transform. |
| 165 | mainTransform.Transform.Tables.Remove("Media"); | 165 | mainTransform.Transform.Tables.Remove("Media"); |
| 166 | mainTransform.Transform.Tables.Remove("WixMedia"); | ||
| 167 | mainTransform.Transform.Tables.Remove("MsiDigitalSignature"); | 166 | mainTransform.Transform.Tables.Remove("MsiDigitalSignature"); |
| 168 | 167 | ||
| 169 | var pairedTransform = this.BuildPairedTransform(summaryInfo, patchMetadata, patchIdTuple, mainTransform.Transform, mediaTuple, baselineTuple, out var productCode); | 168 | var pairedTransform = this.BuildPairedTransform(summaryInfo, patchMetadata, patchIdTuple, mainTransform.Transform, mediaTuple, baselineTuple, out var productCode); |
| @@ -767,15 +766,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 767 | if (transform.TryGetTable("File", out var fileTable)) | 766 | if (transform.TryGetTable("File", out var fileTable)) |
| 768 | { | 767 | { |
| 769 | var componentWithChangedKeyPath = new Dictionary<string, string>(); | 768 | var componentWithChangedKeyPath = new Dictionary<string, string>(); |
| 770 | foreach (var row in fileTable.Rows) | 769 | foreach (FileRow row in fileTable.Rows) |
| 771 | { | 770 | { |
| 772 | if (RowOperation.None == row.Operation) | 771 | if (RowOperation.None == row.Operation) |
| 773 | { | 772 | { |
| 774 | continue; | 773 | continue; |
| 775 | } | 774 | } |
| 776 | 775 | ||
| 777 | var fileId = row.FieldAsString(0); | 776 | var fileId = row.File; |
| 778 | var componentId = row.FieldAsString(1); | 777 | var componentId = row.Component; |
| 779 | 778 | ||
| 780 | // If this file is the keypath of a component | 779 | // If this file is the keypath of a component |
| 781 | if (componentKeyPath.TryGetValue(componentId, out var keyPath) && keyPath.Equals(fileId, StringComparison.Ordinal)) | 780 | if (componentKeyPath.TryGetValue(componentId, out var keyPath) && keyPath.Equals(fileId, StringComparison.Ordinal)) |
| @@ -972,7 +971,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 972 | 971 | ||
| 973 | if (row.Operation == RowOperation.None) | 972 | if (row.Operation == RowOperation.None) |
| 974 | { | 973 | { |
| 975 | // ignore the rows without section id. | 974 | // Ignore the rows without section id. |
| 976 | if (isSectionIdEmpty) | 975 | if (isSectionIdEmpty) |
| 977 | { | 976 | { |
| 978 | currentTable.Rows.RemoveAt(i); | 977 | currentTable.Rows.RemoveAt(i); |
| @@ -1157,47 +1156,33 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 1157 | return null; | 1156 | return null; |
| 1158 | } | 1157 | } |
| 1159 | 1158 | ||
| 1160 | // copy File table | 1159 | // Copy File table |
| 1161 | if (mainTransform.Tables.TryGetTable("File", out var mainFileTable) && 0 < mainFileTable.Rows.Count) | 1160 | if (mainTransform.Tables.TryGetTable("File", out var mainFileTable) && 0 < mainFileTable.Rows.Count) |
| 1162 | { | 1161 | { |
| 1163 | #if TODO_PATCHING | ||
| 1164 | // We require file source information. | ||
| 1165 | var mainWixFileTable = mainTransform.Tables["WixFile"]; | ||
| 1166 | if (null == mainWixFileTable) | ||
| 1167 | { | ||
| 1168 | this.Messaging.Write(ErrorMessages.AdminImageRequired(productCode)); | ||
| 1169 | return null; | ||
| 1170 | } | ||
| 1171 | |||
| 1172 | var mainFileRows = new RowDictionary<FileRow>(mainFileTable); | ||
| 1173 | |||
| 1174 | var pairedFileTable = pairedTransform.EnsureTable(mainFileTable.Definition); | 1162 | var pairedFileTable = pairedTransform.EnsureTable(mainFileTable.Definition); |
| 1175 | { | ||
| 1176 | var mainFileRow = mainFileRows[mainWixFileRow.File]; | ||
| 1177 | 1163 | ||
| 1178 | // set File.Sequence to non null to satisfy transform bind | 1164 | foreach (FileRow mainFileRow in mainFileTable.Rows) |
| 1165 | { | ||
| 1166 | // Set File.Sequence to non null to satisfy transform bind. | ||
| 1179 | mainFileRow.Sequence = 1; | 1167 | mainFileRow.Sequence = 1; |
| 1180 | 1168 | ||
| 1181 | // delete's don't need rows in the paired transform | 1169 | // Delete's don't need rows in the paired transform. |
| 1182 | if (mainFileRow.Operation == RowOperation.Delete) | 1170 | if (mainFileRow.Operation == RowOperation.Delete) |
| 1183 | { | 1171 | { |
| 1184 | continue; | 1172 | continue; |
| 1185 | } | 1173 | } |
| 1186 | 1174 | ||
| 1187 | var pairedFileRow = (FileRow)pairedFileTable.CreateRow(null); | 1175 | var pairedFileRow = (FileRow)pairedFileTable.CreateRow(mainFileRow.SourceLineNumbers); |
| 1188 | pairedFileRow.Operation = RowOperation.Modify; | 1176 | pairedFileRow.Operation = RowOperation.Modify; |
| 1189 | for (var i = 0; i < mainFileRow.Fields.Length; i++) | 1177 | mainFileRow.CopyTo(pairedFileRow); |
| 1190 | { | ||
| 1191 | pairedFileRow[i] = mainFileRow[i]; | ||
| 1192 | } | ||
| 1193 | 1178 | ||
| 1194 | // override authored media for patch bind | 1179 | // Override authored media for patch bind. |
| 1195 | mainWixFileRow.DiskId = mediaTuple.DiskId; | 1180 | mainFileRow.DiskId = mediaTuple.DiskId; |
| 1196 | 1181 | ||
| 1197 | // suppress any change to File.Sequence to avoid bloat | 1182 | // Suppress any change to File.Sequence to avoid bloat. |
| 1198 | mainFileRow.Fields[7].Modified = false; | 1183 | mainFileRow.Fields[7].Modified = false; |
| 1199 | 1184 | ||
| 1200 | // force File row to appear in the transform | 1185 | // Force File row to appear in the transform. |
| 1201 | switch (mainFileRow.Operation) | 1186 | switch (mainFileRow.Operation) |
| 1202 | { | 1187 | { |
| 1203 | case RowOperation.Modify: | 1188 | case RowOperation.Modify: |
| @@ -1211,19 +1196,18 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 1211 | break; | 1196 | break; |
| 1212 | } | 1197 | } |
| 1213 | } | 1198 | } |
| 1214 | #endif | ||
| 1215 | } | 1199 | } |
| 1216 | 1200 | ||
| 1217 | // Add Media row to pairedTransform | 1201 | // Add Media row to pairedTransform |
| 1218 | var pairedMediaTable = pairedTransform.EnsureTable(this.tableDefinitions["Media"]); | 1202 | var pairedMediaTable = pairedTransform.EnsureTable(this.tableDefinitions["Media"]); |
| 1219 | var pairedMediaRow = pairedMediaTable.CreateRow(mediaTuple.SourceLineNumbers); | 1203 | var pairedMediaRow = (MediaRow)pairedMediaTable.CreateRow(mediaTuple.SourceLineNumbers); |
| 1220 | pairedMediaRow.Operation = RowOperation.Add; | 1204 | pairedMediaRow.Operation = RowOperation.Add; |
| 1221 | pairedMediaRow[0] = mediaTuple.DiskId; | 1205 | pairedMediaRow.DiskId = mediaTuple.DiskId; |
| 1222 | pairedMediaRow[1] = mediaTuple.LastSequence ?? 0; | 1206 | pairedMediaRow.LastSequence = mediaTuple.LastSequence ?? 0; |
| 1223 | pairedMediaRow[2] = mediaTuple.DiskPrompt; | 1207 | pairedMediaRow.DiskPrompt = mediaTuple.DiskPrompt; |
| 1224 | pairedMediaRow[3] = mediaTuple.Cabinet; | 1208 | pairedMediaRow.Cabinet = mediaTuple.Cabinet; |
| 1225 | pairedMediaRow[4] = mediaTuple.VolumeLabel; | 1209 | pairedMediaRow.VolumeLabel = mediaTuple.VolumeLabel; |
| 1226 | pairedMediaRow[5] = mediaTuple.Source; | 1210 | pairedMediaRow.Source = mediaTuple.Source; |
| 1227 | 1211 | ||
| 1228 | // Add PatchPackage for this Media | 1212 | // Add PatchPackage for this Media |
| 1229 | var pairedPackageTable = pairedTransform.EnsureTable(this.tableDefinitions["PatchPackage"]); | 1213 | var pairedPackageTable = pairedTransform.EnsureTable(this.tableDefinitions["PatchPackage"]); |
| @@ -1283,7 +1267,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 1283 | { | 1267 | { |
| 1284 | var patchTargetTuples = tuples.OfType<WixPatchTargetTuple>().ToList(); | 1268 | var patchTargetTuples = tuples.OfType<WixPatchTargetTuple>().ToList(); |
| 1285 | 1269 | ||
| 1286 | if (patchTargetTuples.Count > 0) | 1270 | if (patchTargetTuples.Any()) |
| 1287 | { | 1271 | { |
| 1288 | var targets = new SortedSet<string>(); | 1272 | var targets = new SortedSet<string>(); |
| 1289 | var replace = true; | 1273 | var replace = true; |
