aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-03-14 11:27:44 -0500
committerRob Mensching <rob@firegiant.com>2021-03-14 09:40:59 -0700
commitdad79129d26cfb12f0d8894d9189334fa982b823 (patch)
tree8ba6ed0bf7cb707eaf2a91f242b1a80089d7ace2 /src/WixToolset.Core
parent3ccd5e439da4296d6f2b66ce47075ab20d039676 (diff)
downloadwix-dad79129d26cfb12f0d8894d9189334fa982b823.tar.gz
wix-dad79129d26cfb12f0d8894d9189334fa982b823.tar.bz2
wix-dad79129d26cfb12f0d8894d9189334fa982b823.zip
Remove references to Core from backends.
#6340
Diffstat (limited to 'src/WixToolset.Core')
-rw-r--r--src/WixToolset.Core/UnbindContext.cs29
-rw-r--r--src/WixToolset.Core/Unbinder.cs98
-rw-r--r--src/WixToolset.Core/WixToolsetServiceProvider.cs2
3 files changed, 129 insertions, 0 deletions
diff --git a/src/WixToolset.Core/UnbindContext.cs b/src/WixToolset.Core/UnbindContext.cs
new file mode 100644
index 00000000..acfb8f1e
--- /dev/null
+++ b/src/WixToolset.Core/UnbindContext.cs
@@ -0,0 +1,29 @@
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
4{
5 using WixToolset.Extensibility.Data;
6 using WixToolset.Extensibility.Services;
7
8 internal class UnbindContext : IUnbindContext
9 {
10 internal UnbindContext(IWixToolsetServiceProvider serviceProvider)
11 {
12 this.ServiceProvider = serviceProvider;
13 }
14
15 public IWixToolsetServiceProvider ServiceProvider { get; }
16
17 public string ExportBasePath { get; set; }
18
19 public string InputFilePath { get; set; }
20
21 public string IntermediateFolder { get; set; }
22
23 public bool IsAdminImage { get; set; }
24
25 public bool SuppressExtractCabinets { get; set; }
26
27 public bool SuppressDemodularization { get; set; }
28 }
29}
diff --git a/src/WixToolset.Core/Unbinder.cs b/src/WixToolset.Core/Unbinder.cs
new file mode 100644
index 00000000..f712ec3f
--- /dev/null
+++ b/src/WixToolset.Core/Unbinder.cs
@@ -0,0 +1,98 @@
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
4{
5 using System.Collections.Generic;
6 using System.IO;
7 using WixToolset.Data;
8 using WixToolset.Extensibility;
9 using WixToolset.Extensibility.Services;
10
11 /// <summary>
12 /// Unbinder core of the WiX toolset.
13 /// </summary>
14 internal sealed class Unbinder : IUnbinder
15 {
16 public Unbinder(IWixToolsetServiceProvider serviceProvider)
17 {
18 this.ServiceProvider = serviceProvider;
19
20 var extensionManager = this.ServiceProvider.GetService<IExtensionManager>();
21 this.BackendFactories = extensionManager.GetServices<IBackendFactory>();
22 }
23
24 public IWixToolsetServiceProvider ServiceProvider { get; }
25
26 public IEnumerable<IBackendFactory> BackendFactories { get; }
27
28 /// <summary>
29 /// Gets or sets whether the input msi is an admin image.
30 /// </summary>
31 /// <value>Set to true if the input msi is part of an admin image.</value>
32 public bool IsAdminImage { get; set; }
33
34 /// <summary>
35 /// Gets or sets the option to suppress demodularizing values.
36 /// </summary>
37 /// <value>The option to suppress demodularizing values.</value>
38 public bool SuppressDemodularization { get; set; }
39
40 /// <summary>
41 /// Gets or sets the option to suppress extracting cabinets.
42 /// </summary>
43 /// <value>The option to suppress extracting cabinets.</value>
44 public bool SuppressExtractCabinets { get; set; }
45
46 /// <summary>
47 /// Gets or sets the temporary path for the Binder. If left null, the binder
48 /// will use %TEMP% environment variable.
49 /// </summary>
50 /// <value>Path to temp files.</value>
51 public string TempFilesLocation => Path.GetTempPath();
52
53 /// <summary>
54 /// Unbind a Windows Installer file.
55 /// </summary>
56 /// <param name="file">The Windows Installer file.</param>
57 /// <param name="outputType">The type of output to create.</param>
58 /// <param name="exportBasePath">The path where files should be exported.</param>
59 /// <returns>The output representing the database.</returns>
60 public Intermediate Unbind(string file, OutputType outputType, string exportBasePath)
61 {
62 if (!File.Exists(file))
63 {
64 if (OutputType.Transform == outputType)
65 {
66 throw new WixException(ErrorMessages.FileNotFound(null, file, "Transform"));
67 }
68 else
69 {
70 throw new WixException(ErrorMessages.FileNotFound(null, file, "Database"));
71 }
72 }
73
74 // if we don't have the temporary files object yet, get one
75 Directory.CreateDirectory(this.TempFilesLocation); // ensure the base path is there
76
77 var context = new UnbindContext(this.ServiceProvider);
78 context.InputFilePath = file;
79 context.ExportBasePath = exportBasePath;
80 context.IntermediateFolder = this.TempFilesLocation;
81 context.IsAdminImage = this.IsAdminImage;
82 context.SuppressDemodularization = this.SuppressDemodularization;
83 context.SuppressExtractCabinets = this.SuppressExtractCabinets;
84
85 foreach (var factory in this.BackendFactories)
86 {
87 if (factory.TryCreateBackend(outputType.ToString(), file, out var backend))
88 {
89 return backend.Unbind(context);
90 }
91 }
92
93 // TODO: Display message that could not find a unbinder for output type?
94
95 return null;
96 }
97 }
98}
diff --git a/src/WixToolset.Core/WixToolsetServiceProvider.cs b/src/WixToolset.Core/WixToolsetServiceProvider.cs
index d4f186de..87a6f76b 100644
--- a/src/WixToolset.Core/WixToolsetServiceProvider.cs
+++ b/src/WixToolset.Core/WixToolsetServiceProvider.cs
@@ -40,6 +40,7 @@ namespace WixToolset.Core
40 this.AddService<IDecompileContext>((provider, singletons) => new DecompileContext(provider)); 40 this.AddService<IDecompileContext>((provider, singletons) => new DecompileContext(provider));
41 this.AddService<ILayoutContext>((provider, singletons) => new LayoutContext(provider)); 41 this.AddService<ILayoutContext>((provider, singletons) => new LayoutContext(provider));
42 this.AddService<IInscribeContext>((provider, singletons) => new InscribeContext(provider)); 42 this.AddService<IInscribeContext>((provider, singletons) => new InscribeContext(provider));
43 this.AddService<IUnbindContext>((provider, singletons) => new UnbindContext(provider));
43 44
44 this.AddService<IBindFileWithPath>((provider, singletons) => new BindFileWithPath()); 45 this.AddService<IBindFileWithPath>((provider, singletons) => new BindFileWithPath());
45 this.AddService<IBindPath>((provider, singletons) => new BindPath()); 46 this.AddService<IBindPath>((provider, singletons) => new BindPath());
@@ -62,6 +63,7 @@ namespace WixToolset.Core
62 this.AddService<ILibrarian>((provider, singletons) => new Librarian(provider)); 63 this.AddService<ILibrarian>((provider, singletons) => new Librarian(provider));
63 this.AddService<ILinker>((provider, singletons) => new Linker(provider)); 64 this.AddService<ILinker>((provider, singletons) => new Linker(provider));
64 this.AddService<IResolver>((provider, singletons) => new Resolver(provider)); 65 this.AddService<IResolver>((provider, singletons) => new Resolver(provider));
66 this.AddService<IUnbinder>((provider, singletons) => new Unbinder(provider));
65 67
66 this.AddService<ILocalizationParser>((provider, singletons) => new LocalizationParser(provider)); 68 this.AddService<ILocalizationParser>((provider, singletons) => new LocalizationParser(provider));
67 this.AddService<IVariableResolver>((provider, singletons) => new VariableResolver(provider)); 69 this.AddService<IVariableResolver>((provider, singletons) => new VariableResolver(provider));