aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2021-02-26 11:24:10 -0800
committerRob Mensching <rob@firegiant.com>2021-02-27 07:47:08 -0800
commit5fd1b7ff82f17d55c8357fe76898a1bdc5953476 (patch)
tree5ec191ebf43009daf9bde6d0c26879b181b9a71b /src/WixToolset.Core.WindowsInstaller
parent760fb810ba5ecc3c6ce752a9bfa3755f7b7c0f6a (diff)
downloadwix-5fd1b7ff82f17d55c8357fe76898a1bdc5953476.tar.gz
wix-5fd1b7ff82f17d55c8357fe76898a1bdc5953476.tar.bz2
wix-5fd1b7ff82f17d55c8357fe76898a1bdc5953476.zip
Absorb Dependency.wixext into Core
Partly resolves wixtoolset/issues#5949
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs12
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/ProcessDependencyReferencesCommand.cs111
2 files changed, 123 insertions, 0 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
index 25a093fd..a3f2da94 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
@@ -325,6 +325,18 @@ namespace WixToolset.Core.WindowsInstaller.Bind
325 command.Execute(); 325 command.Execute();
326 } 326 }
327 327
328 // Process dependency references.
329 if (SectionType.Product == section.Type || SectionType.Module == section.Type)
330 {
331 var dependencyRefs = section.Symbols.OfType<WixDependencyRefSymbol>().ToList();
332
333 if (dependencyRefs.Any())
334 {
335 var command = new ProcessDependencyReferencesCommand(this.WindowsInstallerBackendHelper, section, dependencyRefs);
336 command.Execute();
337 }
338 }
339
328 // If there are any backend extensions, give them the opportunity to process 340 // If there are any backend extensions, give them the opportunity to process
329 // the section now that the fields have all be resolved. 341 // the section now that the fields have all be resolved.
330 // 342 //
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessDependencyReferencesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessDependencyReferencesCommand.cs
new file mode 100644
index 00000000..899d06e1
--- /dev/null
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessDependencyReferencesCommand.cs
@@ -0,0 +1,111 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.Core.WindowsInstaller.Bind
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Linq;
8 using WixToolset.Data;
9 using WixToolset.Data.Symbols;
10 using WixToolset.Extensibility.Services;
11
12 internal class ProcessDependencyReferencesCommand
13 {
14 // The root registry key for the dependency extension. We write to Software\Classes explicitly
15 // based on the current security context instead of HKCR. See
16 // http://msdn.microsoft.com/en-us/library/ms724475(VS.85).aspx for more information.
17 private const string DependencyRegistryRoot = @"Software\Classes\Installer\Dependencies\";
18 private const string RegistryDependents = "Dependents";
19
20 public ProcessDependencyReferencesCommand(IWindowsInstallerBackendHelper backendHelper, IntermediateSection section, IEnumerable<WixDependencyRefSymbol> dependencyRefSymbols)
21 {
22 this.Section = section;
23 this.DependencyRefSymbols = dependencyRefSymbols;
24 }
25
26 private IntermediateSection Section { get; }
27
28 private IEnumerable<WixDependencyRefSymbol> DependencyRefSymbols { get; }
29
30 public void Execute()
31 {
32 var wixDependencyRows = this.Section.Symbols.OfType<WixDependencySymbol>().ToDictionary(d => d.Id.Id);
33 var wixDependencyProviderRows = this.Section.Symbols.OfType<WixDependencyProviderSymbol>().ToDictionary(d => d.Id.Id);
34
35 // For each relationship, get the provides and requires rows to generate registry values.
36 foreach (var wixDependencyRefRow in this.DependencyRefSymbols)
37 {
38 var providesId = wixDependencyRefRow.WixDependencyProviderRef;
39 var requiresId = wixDependencyRefRow.WixDependencyRef;
40
41 // If we do not find both symbols, skip the registry key generation.
42 if (!wixDependencyRows.TryGetValue(requiresId, out var wixDependencyRow))
43 {
44 continue;
45 }
46
47 if (!wixDependencyProviderRows.TryGetValue(providesId, out var wixDependencyProviderRow))
48 {
49 continue;
50 }
51
52 // Format the root registry key using the required provider key and the current provider key.
53 var requiresKey = wixDependencyRow.Id.Id;
54 var providesKey = wixDependencyRow.ProviderKey;
55 var keyRequires = String.Format(@"{0}{1}\{2}\{3}", DependencyRegistryRoot, requiresKey, RegistryDependents, providesKey);
56
57 // Get the component ID from the provider.
58 var componentId = wixDependencyProviderRow.ComponentRef;
59
60 var id = Common.GenerateIdentifier("reg", providesId, requiresId, "(Default)");
61 this.Section.AddSymbol(new RegistrySymbol(wixDependencyRefRow.SourceLineNumbers, new Identifier(AccessModifier.Private, id))
62 {
63 ComponentRef = componentId,
64 Root = RegistryRootType.MachineUser,
65 Key = keyRequires,
66 Name = "*",
67 });
68
69 if (!String.IsNullOrEmpty(wixDependencyRow.MinVersion))
70 {
71 id = Common.GenerateIdentifier("reg", providesId, requiresId, "MinVersion");
72 this.Section.AddSymbol(new RegistrySymbol(wixDependencyRefRow.SourceLineNumbers, new Identifier(AccessModifier.Private, id))
73 {
74 ComponentRef = componentId,
75 Root = RegistryRootType.MachineUser,
76 Key = keyRequires,
77 Name = "MinVersion",
78 Value = wixDependencyRow.MinVersion
79 });
80 }
81
82 string maxVersion = (string)wixDependencyRow[3];
83 if (!String.IsNullOrEmpty(wixDependencyRow.MaxVersion))
84 {
85 id = Common.GenerateIdentifier("reg", providesId, requiresId, "MaxVersion");
86 this.Section.AddSymbol(new RegistrySymbol(wixDependencyRefRow.SourceLineNumbers, new Identifier(AccessModifier.Private, id))
87 {
88 ComponentRef = componentId,
89 Root = RegistryRootType.MachineUser,
90 Key = keyRequires,
91 Name = "MaxVersion",
92 Value = wixDependencyRow.MaxVersion
93 });
94 }
95
96 if (wixDependencyRow.Attributes != WixDependencySymbolAttributes.None)
97 {
98 id = Common.GenerateIdentifier("reg", providesId, requiresId, "Attributes");
99 this.Section.AddSymbol(new RegistrySymbol(wixDependencyRefRow.SourceLineNumbers, new Identifier(AccessModifier.Private, id))
100 {
101 ComponentRef = componentId,
102 Root = RegistryRootType.MachineUser,
103 Key = keyRequires,
104 Name = "Attributes",
105 Value = String.Concat("#", (int)wixDependencyRow.Attributes)
106 });
107 }
108 }
109 }
110 }
111}