diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2019-11-26 08:24:48 +1000 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2019-11-26 08:30:11 +1000 |
commit | dda4a326407eb8a0fb5d094ee1e2b5b85d419042 (patch) | |
tree | 2e29c663282ed3cd93bbbe7636e4cca662c56777 /src | |
parent | 2c73e671599f4d05bb98b38dbc79750a1cf04b45 (diff) | |
download | wix-dda4a326407eb8a0fb5d094ee1e2b5b85d419042.tar.gz wix-dda4a326407eb8a0fb5d094ee1e2b5b85d419042.tar.bz2 wix-dda4a326407eb8a0fb5d094ee1e2b5b85d419042.zip |
Fix decompiling multiple AppSearches with nested searches.
Diffstat (limited to 'src')
3 files changed, 35 insertions, 10 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs index 961e1a13..b1222d3d 100644 --- a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs +++ b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs | |||
@@ -2000,7 +2000,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
2000 | var drLocators = new Hashtable(); | 2000 | var drLocators = new Hashtable(); |
2001 | var locators = new Hashtable(); | 2001 | var locators = new Hashtable(); |
2002 | var usedSearchElements = new Hashtable(); | 2002 | var usedSearchElements = new Hashtable(); |
2003 | var unusedSearchElements = new ArrayList(); | 2003 | var unusedSearchElements = new Dictionary<string, Wix.IParentElement>(); |
2004 | 2004 | ||
2005 | Wix.ComplianceCheck complianceCheck = null; | 2005 | Wix.ComplianceCheck complianceCheck = null; |
2006 | 2006 | ||
@@ -2131,6 +2131,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
2131 | } | 2131 | } |
2132 | else if ("DrLocator" == locatorRow.TableDefinition.Name && null != locatorRow[1]) | 2132 | else if ("DrLocator" == locatorRow.TableDefinition.Name && null != locatorRow[1]) |
2133 | { | 2133 | { |
2134 | var drSearchElement = (Wix.DirectorySearch)searchElement; | ||
2134 | var parentSignature = Convert.ToString(locatorRow[1]); | 2135 | var parentSignature = Convert.ToString(locatorRow[1]); |
2135 | 2136 | ||
2136 | if ("CCP_DRIVE" == parentSignature) | 2137 | if ("CCP_DRIVE" == parentSignature) |
@@ -2266,7 +2267,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
2266 | } | 2267 | } |
2267 | 2268 | ||
2268 | parentSearchElement = directorySeachRef; | 2269 | parentSearchElement = directorySeachRef; |
2269 | unusedSearchElements.Add(directorySeachRef); | 2270 | unusedSearchElements.Add(directorySeachRef.Id, directorySeachRef); |
2270 | } | 2271 | } |
2271 | 2272 | ||
2272 | if (!usedSearchElements.Contains(searchElement)) | 2273 | if (!usedSearchElements.Contains(searchElement)) |
@@ -2305,7 +2306,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
2305 | // keep track of unused DrLocator rows | 2306 | // keep track of unused DrLocator rows |
2306 | if (!usedDrLocator) | 2307 | if (!usedDrLocator) |
2307 | { | 2308 | { |
2308 | unusedSearchElements.Add(searchElement); | 2309 | unusedSearchElements.Add(drSearchElement.Id, drSearchElement); |
2309 | } | 2310 | } |
2310 | } | 2311 | } |
2311 | else | 2312 | else |
@@ -2370,10 +2371,13 @@ namespace WixToolset.Core.WindowsInstaller | |||
2370 | } | 2371 | } |
2371 | else | 2372 | else |
2372 | { | 2373 | { |
2373 | if ("DrLocator" == locatorRow.TableDefinition.Name || | 2374 | if (searchElement is Wix.DirectorySearch directorySearch) |
2374 | "RegLocator" == locatorRow.TableDefinition.Name) | ||
2375 | { | 2375 | { |
2376 | unusedSearchElements.Add(searchElement); | 2376 | unusedSearchElements.Add(directorySearch.Id, directorySearch); |
2377 | } | ||
2378 | else if (searchElement is Wix.RegistrySearch registrySearch) | ||
2379 | { | ||
2380 | unusedSearchElements.Add(registrySearch.Id, registrySearch); | ||
2377 | } | 2381 | } |
2378 | else | 2382 | else |
2379 | { | 2383 | { |
@@ -2390,8 +2394,12 @@ namespace WixToolset.Core.WindowsInstaller | |||
2390 | } | 2394 | } |
2391 | } | 2395 | } |
2392 | 2396 | ||
2393 | foreach (Wix.IParentElement unusedSearchElement in unusedSearchElements) | 2397 | // Iterate through the unused elements through a sorted list of their ids so the output is deterministic. |
2398 | var unusedSearchElementKeys = unusedSearchElements.Keys.ToList(); | ||
2399 | unusedSearchElementKeys.Sort(); | ||
2400 | foreach (var unusedSearchElementKey in unusedSearchElementKeys) | ||
2394 | { | 2401 | { |
2402 | var unusedSearchElement = unusedSearchElements[unusedSearchElementKey]; | ||
2395 | var used = false; | 2403 | var used = false; |
2396 | 2404 | ||
2397 | Wix.DirectorySearch leafDirectorySearch = null; | 2405 | Wix.DirectorySearch leafDirectorySearch = null; |
@@ -2422,13 +2430,11 @@ namespace WixToolset.Core.WindowsInstaller | |||
2422 | 2430 | ||
2423 | property.AddChild(unusedSearchSchemaElement); | 2431 | property.AddChild(unusedSearchSchemaElement); |
2424 | used = true; | 2432 | used = true; |
2425 | break; | ||
2426 | } | 2433 | } |
2427 | else if (ccpSearches.Contains(leafDirectorySearch.Id)) | 2434 | else if (ccpSearches.Contains(leafDirectorySearch.Id)) |
2428 | { | 2435 | { |
2429 | complianceCheck.AddChild(unusedSearchSchemaElement); | 2436 | complianceCheck.AddChild(unusedSearchSchemaElement); |
2430 | used = true; | 2437 | used = true; |
2431 | break; | ||
2432 | } | 2438 | } |
2433 | else | 2439 | else |
2434 | { | 2440 | { |
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/AppSearch/DecompiledNestedDirSearchUnderRegSearch.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/AppSearch/DecompiledNestedDirSearchUnderRegSearch.wxs index 6d78b2db..26649485 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/AppSearch/DecompiledNestedDirSearchUnderRegSearch.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/AppSearch/DecompiledNestedDirSearchUnderRegSearch.wxs | |||
@@ -1,6 +1,6 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | 2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> |
3 | <Product Id="{F71CC1C8-8EDC-4FCD-8946-D92AE30B3ABE}" Codepage="1252" Language="1033" Manufacturer="Example Corporation" Name="MsiPackage" UpgradeCode="{12E4699F-E774-4D05-8A01-5BDD41BBA127}" Version="1.0.0.0"> | 3 | <Product Id="{33C58183-7333-4257-AEFD-6705DA66E617}" Codepage="1252" Language="1033" Manufacturer="Example Corporation" Name="MsiPackage" UpgradeCode="{12E4699F-E774-4D05-8A01-5BDD41BBA127}" Version="1.0.0.0"> |
4 | <Package Description="MsiPackage" InstallerVersion="500" Languages="1033" Manufacturer="Example Corporation" Platform="x86" /> | 4 | <Package Description="MsiPackage" InstallerVersion="500" Languages="1033" Manufacturer="Example Corporation" Platform="x86" /> |
5 | <Directory Id="TARGETDIR" Name="SourceDir"> | 5 | <Directory Id="TARGETDIR" Name="SourceDir"> |
6 | <Directory Id="ProgramFilesFolder"> | 6 | <Directory Id="ProgramFilesFolder"> |
@@ -17,6 +17,25 @@ | |||
17 | <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> | 17 | <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> |
18 | <Media Id="1" /> | 18 | <Media Id="1" /> |
19 | <Property Id="ALLUSERS" Value="1" /> | 19 | <Property Id="ALLUSERS" Value="1" /> |
20 | <Property Id="SAMPLEREGFOUND"> | ||
21 | <RegistrySearch Id="RegSearch" Root="HKLM" Key="Reg" Type="raw" Win64="no" /> | ||
22 | </Property> | ||
23 | <Property Id="NESTEDDIRFOUND"> | ||
24 | <RegistrySearch Id="ARegKeySearch" Root="HKLM" Key="ARegKey" Type="raw" Win64="no"> | ||
25 | <DirectorySearch Id="TopDirSearch" Path="TopDir"> | ||
26 | <DirectorySearch Id="SecondDirSearch" Path="SecondDir"> | ||
27 | <DirectorySearch Id="ThirdDirSearch" Path="ThirdDir"> | ||
28 | <DirectorySearch Id="FourthDirSearch" Path="FourthDir" /> | ||
29 | </DirectorySearch> | ||
30 | </DirectorySearch> | ||
31 | </DirectorySearch> | ||
32 | </RegistrySearch> | ||
33 | </Property> | ||
34 | <Property Id="SAMPLENESTEDDIRFOUND"> | ||
35 | <RegistrySearch Id="NestedRegSearch" Root="HKLM" Key="NestedReg" Type="raw" Win64="no"> | ||
36 | <DirectorySearch Id="SampleNestedDirSearch" Path="NestedDir" /> | ||
37 | </RegistrySearch> | ||
38 | </Property> | ||
20 | <Property Id="SAMPLEDIRFOUND"> | 39 | <Property Id="SAMPLEDIRFOUND"> |
21 | <RegistrySearch Id="SubRegSearch" Root="HKLM" Key="SampleReg" Type="raw" Win64="no"> | 40 | <RegistrySearch Id="SubRegSearch" Root="HKLM" Key="SampleReg" Type="raw" Win64="no"> |
22 | <DirectorySearch Id="SampleDirSearch" Path="SampleDir"> | 41 | <DirectorySearch Id="SampleDirSearch" Path="SampleDir"> |
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/AppSearch/NestedDirSearchUnderRegSearch.msi b/src/test/WixToolsetTest.CoreIntegration/TestData/AppSearch/NestedDirSearchUnderRegSearch.msi index 7e0f8060..ea1296c3 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/AppSearch/NestedDirSearchUnderRegSearch.msi +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/AppSearch/NestedDirSearchUnderRegSearch.msi | |||
Binary files differ | |||