diff options
Diffstat (limited to 'src/WixToolset.Core/Unbinder.cs')
-rw-r--r-- | src/WixToolset.Core/Unbinder.cs | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/src/WixToolset.Core/Unbinder.cs b/src/WixToolset.Core/Unbinder.cs deleted file mode 100644 index 2ff51997..00000000 --- a/src/WixToolset.Core/Unbinder.cs +++ /dev/null | |||
@@ -1,132 +0,0 @@ | |||
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.Core | ||
4 | { | ||
5 | using System.Collections; | ||
6 | using System.IO; | ||
7 | using WixToolset.Data; | ||
8 | using WixToolset.Extensibility; | ||
9 | using System.Collections.Generic; | ||
10 | |||
11 | /// <summary> | ||
12 | /// Unbinder core of the WiX toolset. | ||
13 | /// </summary> | ||
14 | public sealed class Unbinder | ||
15 | { | ||
16 | private TableDefinitionCollection tableDefinitions; | ||
17 | private ArrayList unbinderExtensions; | ||
18 | // private TempFileCollection tempFiles; | ||
19 | |||
20 | /// <summary> | ||
21 | /// Creates a new unbinder object with a default set of table definitions. | ||
22 | /// </summary> | ||
23 | public Unbinder() | ||
24 | { | ||
25 | this.tableDefinitions = new TableDefinitionCollection(WindowsInstallerStandard.GetTableDefinitions()); | ||
26 | this.unbinderExtensions = new ArrayList(); | ||
27 | } | ||
28 | |||
29 | public IEnumerable<IBackendFactory> BackendFactories { get; } | ||
30 | |||
31 | /// <summary> | ||
32 | /// Gets or sets whether the input msi is an admin image. | ||
33 | /// </summary> | ||
34 | /// <value>Set to true if the input msi is part of an admin image.</value> | ||
35 | public bool IsAdminImage { get; set; } | ||
36 | |||
37 | /// <summary> | ||
38 | /// Gets or sets the option to suppress demodularizing values. | ||
39 | /// </summary> | ||
40 | /// <value>The option to suppress demodularizing values.</value> | ||
41 | public bool SuppressDemodularization { get; set; } | ||
42 | |||
43 | /// <summary> | ||
44 | /// Gets or sets the option to suppress extracting cabinets. | ||
45 | /// </summary> | ||
46 | /// <value>The option to suppress extracting cabinets.</value> | ||
47 | public bool SuppressExtractCabinets { get; set; } | ||
48 | |||
49 | /// <summary> | ||
50 | /// Gets or sets the temporary path for the Binder. If left null, the binder | ||
51 | /// will use %TEMP% environment variable. | ||
52 | /// </summary> | ||
53 | /// <value>Path to temp files.</value> | ||
54 | public string TempFilesLocation => Path.GetTempPath(); | ||
55 | |||
56 | /// <summary> | ||
57 | /// Adds extension data. | ||
58 | /// </summary> | ||
59 | /// <param name="data">The extension data to add.</param> | ||
60 | public void AddExtensionData(IExtensionData data) | ||
61 | { | ||
62 | if (null != data.TableDefinitions) | ||
63 | { | ||
64 | foreach (TableDefinition tableDefinition in data.TableDefinitions) | ||
65 | { | ||
66 | if (!this.tableDefinitions.Contains(tableDefinition.Name)) | ||
67 | { | ||
68 | this.tableDefinitions.Add(tableDefinition); | ||
69 | } | ||
70 | else | ||
71 | { | ||
72 | Messaging.Instance.OnMessage(WixErrors.DuplicateExtensionTable(data.GetType().ToString(), tableDefinition.Name)); | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | |||
78 | /// <summary> | ||
79 | /// Adds an extension. | ||
80 | /// </summary> | ||
81 | /// <param name="extension">The extension to add.</param> | ||
82 | public void AddExtension(IUnbinderExtension extension) | ||
83 | { | ||
84 | this.unbinderExtensions.Add(extension); | ||
85 | } | ||
86 | |||
87 | /// <summary> | ||
88 | /// Unbind a Windows Installer file. | ||
89 | /// </summary> | ||
90 | /// <param name="file">The Windows Installer file.</param> | ||
91 | /// <param name="outputType">The type of output to create.</param> | ||
92 | /// <param name="exportBasePath">The path where files should be exported.</param> | ||
93 | /// <returns>The output representing the database.</returns> | ||
94 | public Output Unbind(string file, OutputType outputType, string exportBasePath) | ||
95 | { | ||
96 | if (!File.Exists(file)) | ||
97 | { | ||
98 | if (OutputType.Transform == outputType) | ||
99 | { | ||
100 | throw new WixException(WixErrors.FileNotFound(null, file, "Transform")); | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | throw new WixException(WixErrors.FileNotFound(null, file, "Database")); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | // if we don't have the temporary files object yet, get one | ||
109 | Directory.CreateDirectory(this.TempFilesLocation); // ensure the base path is there | ||
110 | |||
111 | var context = new UnbindContext(); | ||
112 | context.InputFilePath = file; | ||
113 | context.ExportBasePath = exportBasePath; | ||
114 | context.IntermediateFolder = this.TempFilesLocation; | ||
115 | context.IsAdminImage = this.IsAdminImage; | ||
116 | context.SuppressDemodularization = this.SuppressDemodularization; | ||
117 | context.SuppressExtractCabinets = this.SuppressExtractCabinets; | ||
118 | |||
119 | foreach (var factory in this.BackendFactories) | ||
120 | { | ||
121 | if (factory.TryCreateBackend(outputType.ToString(), file, null, out var backend)) | ||
122 | { | ||
123 | return backend.Unbind(context); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | // TODO: Display message that could not find a unbinder for output type? | ||
128 | |||
129 | return null; | ||
130 | } | ||
131 | } | ||
132 | } | ||