diff options
Diffstat (limited to 'src/tools/heat/AssemblyHarvester.cs')
-rw-r--r-- | src/tools/heat/AssemblyHarvester.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/tools/heat/AssemblyHarvester.cs b/src/tools/heat/AssemblyHarvester.cs new file mode 100644 index 00000000..2304d827 --- /dev/null +++ b/src/tools/heat/AssemblyHarvester.cs | |||
@@ -0,0 +1,41 @@ | |||
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 | |||
3 | namespace WixToolset.Harvesters | ||
4 | { | ||
5 | using System; | ||
6 | using System.Reflection; | ||
7 | using System.Runtime.InteropServices; | ||
8 | using Wix = WixToolset.Harvesters.Serialize; | ||
9 | |||
10 | /// <summary> | ||
11 | /// Harvest WiX authoring from an assembly file. | ||
12 | /// </summary> | ||
13 | public sealed class AssemblyHarvester | ||
14 | { | ||
15 | /// <summary> | ||
16 | /// Harvest the registry values written by RegisterAssembly. | ||
17 | /// </summary> | ||
18 | /// <param name="path">The file to harvest registry values from.</param> | ||
19 | /// <returns>The harvested registry values.</returns> | ||
20 | public Wix.RegistryValue[] HarvestRegistryValues(string path) | ||
21 | { | ||
22 | #if NETCOREAPP | ||
23 | throw new PlatformNotSupportedException(); | ||
24 | #else | ||
25 | RegistrationServices regSvcs = new RegistrationServices(); | ||
26 | Assembly assembly = Assembly.LoadFrom(path); | ||
27 | |||
28 | // must call this before overriding registry hives to prevent binding failures | ||
29 | // on exported types during RegisterAssembly | ||
30 | assembly.GetExportedTypes(); | ||
31 | |||
32 | using (RegistryHarvester registryHarvester = new RegistryHarvester(true)) | ||
33 | { | ||
34 | regSvcs.RegisterAssembly(assembly, AssemblyRegistrationFlags.SetCodeBase); | ||
35 | |||
36 | return registryHarvester.HarvestRegistry(); | ||
37 | } | ||
38 | #endif | ||
39 | } | ||
40 | } | ||
41 | } | ||