diff options
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs index 5412c6f9..49b6a6f8 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs | |||
| @@ -48,7 +48,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 48 | { | 48 | { |
| 49 | var mergeModulesFileFacades = new List<FileFacade>(); | 49 | var mergeModulesFileFacades = new List<FileFacade>(); |
| 50 | 50 | ||
| 51 | IMsmMerge2 merge = MsmInterop.GetMsmMerge(); | 51 | var merge = MsmInterop.GetMsmMerge(); |
| 52 | 52 | ||
| 53 | // Index all of the file rows to be able to detect collisions with files in the Merge Modules. | 53 | // Index all of the file rows to be able to detect collisions with files in the Merge Modules. |
| 54 | // It may seem a bit expensive to build up this index solely for the purpose of checking collisions | 54 | // It may seem a bit expensive to build up this index solely for the purpose of checking collisions |
| @@ -57,11 +57,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 57 | // Now since Merge Modules are already slow and generally less desirable than .wixlibs we'll let | 57 | // Now since Merge Modules are already slow and generally less desirable than .wixlibs we'll let |
| 58 | // this case be slightly more expensive because the cost of maintaining an indexed file row collection | 58 | // this case be slightly more expensive because the cost of maintaining an indexed file row collection |
| 59 | // is a lot more costly for the common cases. | 59 | // is a lot more costly for the common cases. |
| 60 | var indexedFileFacades = this.FileFacades.ToDictionary(f => f.File.Id.Id, StringComparer.Ordinal); | 60 | var indexedFileFacades = this.FileFacades.ToDictionary(f => f.Id, StringComparer.Ordinal); |
| 61 | 61 | ||
| 62 | foreach (var wixMergeRow in this.WixMergeTuples) | 62 | foreach (var wixMergeRow in this.WixMergeTuples) |
| 63 | { | 63 | { |
| 64 | bool containsFiles = this.CreateFacadesForMergeModuleFiles(wixMergeRow, mergeModulesFileFacades, indexedFileFacades); | 64 | var containsFiles = this.CreateFacadesForMergeModuleFiles(wixMergeRow, mergeModulesFileFacades, indexedFileFacades); |
| 65 | 65 | ||
| 66 | // If the module has files and creating layout | 66 | // If the module has files and creating layout |
| 67 | if (containsFiles && !this.SuppressLayout) | 67 | if (containsFiles && !this.SuppressLayout) |
| @@ -75,21 +75,21 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 75 | 75 | ||
| 76 | private bool CreateFacadesForMergeModuleFiles(WixMergeTuple wixMergeRow, List<FileFacade> mergeModulesFileFacades, Dictionary<string, FileFacade> indexedFileFacades) | 76 | private bool CreateFacadesForMergeModuleFiles(WixMergeTuple wixMergeRow, List<FileFacade> mergeModulesFileFacades, Dictionary<string, FileFacade> indexedFileFacades) |
| 77 | { | 77 | { |
| 78 | bool containsFiles = false; | 78 | var containsFiles = false; |
| 79 | 79 | ||
| 80 | try | 80 | try |
| 81 | { | 81 | { |
| 82 | // read the module's File table to get its FileMediaInformation entries and gather any other information needed from the module. | 82 | // read the module's File table to get its FileMediaInformation entries and gather any other information needed from the module. |
| 83 | using (Database db = new Database(wixMergeRow.SourceFile, OpenDatabase.ReadOnly)) | 83 | using (var db = new Database(wixMergeRow.SourceFile, OpenDatabase.ReadOnly)) |
| 84 | { | 84 | { |
| 85 | if (db.TableExists("File") && db.TableExists("Component")) | 85 | if (db.TableExists("File") && db.TableExists("Component")) |
| 86 | { | 86 | { |
| 87 | Dictionary<string, FileFacade> uniqueModuleFileIdentifiers = new Dictionary<string, FileFacade>(StringComparer.OrdinalIgnoreCase); | 87 | var uniqueModuleFileIdentifiers = new Dictionary<string, FileFacade>(StringComparer.OrdinalIgnoreCase); |
| 88 | 88 | ||
| 89 | using (View view = db.OpenExecuteView("SELECT `File`, `Directory_` FROM `File`, `Component` WHERE `Component_`=`Component`")) | 89 | using (var view = db.OpenExecuteView("SELECT `File`, `Directory_` FROM `File`, `Component` WHERE `Component_`=`Component`")) |
| 90 | { | 90 | { |
| 91 | // add each file row from the merge module into the file row collection (check for errors along the way) | 91 | // add each file row from the merge module into the file row collection (check for errors along the way) |
| 92 | foreach (Record record in view.Records) | 92 | foreach (var record in view.Records) |
| 93 | { | 93 | { |
| 94 | // NOTE: this is very tricky - the merge module file rows are not added to the | 94 | // NOTE: this is very tricky - the merge module file rows are not added to the |
| 95 | // file table because they should not be created via idt import. Instead, these | 95 | // file table because they should not be created via idt import. Instead, these |
| @@ -103,21 +103,21 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 103 | var mergeModuleFileFacade = new FileFacade(true, fileTuple); | 103 | var mergeModuleFileFacade = new FileFacade(true, fileTuple); |
| 104 | 104 | ||
| 105 | // If case-sensitive collision with another merge module or a user-authored file identifier. | 105 | // If case-sensitive collision with another merge module or a user-authored file identifier. |
| 106 | if (indexedFileFacades.TryGetValue(mergeModuleFileFacade.File.Id.Id, out var collidingFacade)) | 106 | if (indexedFileFacades.TryGetValue(mergeModuleFileFacade.Id, out var collidingFacade)) |
| 107 | { | 107 | { |
| 108 | this.Messaging.Write(ErrorMessages.DuplicateModuleFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, collidingFacade.File.Id.Id)); | 108 | this.Messaging.Write(ErrorMessages.DuplicateModuleFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, collidingFacade.Id)); |
| 109 | } | 109 | } |
| 110 | else if (uniqueModuleFileIdentifiers.TryGetValue(mergeModuleFileFacade.File.Id.Id, out collidingFacade)) // case-insensitive collision with another file identifier in the same merge module | 110 | else if (uniqueModuleFileIdentifiers.TryGetValue(mergeModuleFileFacade.Id, out collidingFacade)) // case-insensitive collision with another file identifier in the same merge module |
| 111 | { | 111 | { |
| 112 | this.Messaging.Write(ErrorMessages.DuplicateModuleCaseInsensitiveFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, mergeModuleFileFacade.File.Id.Id, collidingFacade.File.Id.Id)); | 112 | this.Messaging.Write(ErrorMessages.DuplicateModuleCaseInsensitiveFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, mergeModuleFileFacade.Id, collidingFacade.Id)); |
| 113 | } | 113 | } |
| 114 | else // no collision | 114 | else // no collision |
| 115 | { | 115 | { |
| 116 | mergeModulesFileFacades.Add(mergeModuleFileFacade); | 116 | mergeModulesFileFacades.Add(mergeModuleFileFacade); |
| 117 | 117 | ||
| 118 | // Keep updating the indexes as new rows are added. | 118 | // Keep updating the indexes as new rows are added. |
| 119 | indexedFileFacades.Add(mergeModuleFileFacade.File.Id.Id, mergeModuleFileFacade); | 119 | indexedFileFacades.Add(mergeModuleFileFacade.Id, mergeModuleFileFacade); |
| 120 | uniqueModuleFileIdentifiers.Add(mergeModuleFileFacade.File.Id.Id, mergeModuleFileFacade); | 120 | uniqueModuleFileIdentifiers.Add(mergeModuleFileFacade.Id, mergeModuleFileFacade); |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | containsFiles = true; | 123 | containsFiles = true; |
| @@ -126,13 +126,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | // Get the summary information to detect the Schema | 128 | // Get the summary information to detect the Schema |
| 129 | using (SummaryInformation summaryInformation = new SummaryInformation(db)) | 129 | using (var summaryInformation = new SummaryInformation(db)) |
| 130 | { | 130 | { |
| 131 | string moduleInstallerVersionString = summaryInformation.GetProperty(14); | 131 | var moduleInstallerVersionString = summaryInformation.GetProperty(14); |
| 132 | 132 | ||
| 133 | try | 133 | try |
| 134 | { | 134 | { |
| 135 | int moduleInstallerVersion = Convert.ToInt32(moduleInstallerVersionString, CultureInfo.InvariantCulture); | 135 | var moduleInstallerVersion = Convert.ToInt32(moduleInstallerVersionString, CultureInfo.InvariantCulture); |
| 136 | if (moduleInstallerVersion > this.OutputInstallerVersion) | 136 | if (moduleInstallerVersion > this.OutputInstallerVersion) |
| 137 | { | 137 | { |
| 138 | this.Messaging.Write(WarningMessages.InvalidHigherInstallerVersionInModule(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, moduleInstallerVersion, this.OutputInstallerVersion)); | 138 | this.Messaging.Write(WarningMessages.InvalidHigherInstallerVersionInModule(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, moduleInstallerVersion, this.OutputInstallerVersion)); |
| @@ -159,7 +159,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 159 | 159 | ||
| 160 | private void ExtractFilesFromMergeModule(IMsmMerge2 merge, WixMergeTuple wixMergeRow) | 160 | private void ExtractFilesFromMergeModule(IMsmMerge2 merge, WixMergeTuple wixMergeRow) |
| 161 | { | 161 | { |
| 162 | bool moduleOpen = false; | 162 | var moduleOpen = false; |
| 163 | short mergeLanguage; | 163 | short mergeLanguage; |
| 164 | 164 | ||
| 165 | var mergeId = wixMergeRow.Id.Id; | 165 | var mergeId = wixMergeRow.Id.Id; |
| @@ -180,10 +180,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 180 | moduleOpen = true; | 180 | moduleOpen = true; |
| 181 | 181 | ||
| 182 | // extract the module cabinet, then explode all of the files to a temp directory | 182 | // extract the module cabinet, then explode all of the files to a temp directory |
| 183 | string moduleCabPath = Path.Combine(this.IntermediateFolder, mergeId + ".cab"); | 183 | var moduleCabPath = Path.Combine(this.IntermediateFolder, mergeId + ".cab"); |
| 184 | merge.ExtractCAB(moduleCabPath); | 184 | merge.ExtractCAB(moduleCabPath); |
| 185 | 185 | ||
| 186 | string mergeIdPath = Path.Combine(this.IntermediateFolder, mergeId); | 186 | var mergeIdPath = Path.Combine(this.IntermediateFolder, mergeId); |
| 187 | Directory.CreateDirectory(mergeIdPath); | 187 | Directory.CreateDirectory(mergeIdPath); |
| 188 | 188 | ||
| 189 | try | 189 | try |
