aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2022-03-10 14:18:34 -0800
committerRob Mensching <rob@firegiant.com>2022-03-14 12:50:55 -0700
commit64750a8dd105d89c27613694e1008a454df2a4ee (patch)
tree55827f3654620da0ac1145345ca1423e04c63f40
parent91cd2d65121a163e625d2f029025123b0f8467d2 (diff)
downloadwix-64750a8dd105d89c27613694e1008a454df2a4ee.tar.gz
wix-64750a8dd105d89c27613694e1008a454df2a4ee.tar.bz2
wix-64750a8dd105d89c27613694e1008a454df2a4ee.zip
Remove Unbind as backend function
Unbinding is not a general purpose function as initially imagined.
-rw-r--r--src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs24
-rw-r--r--src/api/wix/WixToolset.Extensibility/IBackend.cs13
-rw-r--r--src/api/wix/WixToolset.Extensibility/IBackendFactory.cs11
-rw-r--r--src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs18
-rw-r--r--src/wix/WixToolset.Core.Burn/BundleBackend.cs1
-rw-r--r--src/wix/WixToolset.Core.WindowsInstaller/MsiBackend.cs5
-rw-r--r--src/wix/WixToolset.Core.WindowsInstaller/MsmBackend.cs5
-rw-r--r--src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs11
-rw-r--r--src/wix/WixToolset.Core/IUnbinder.cs12
-rw-r--r--src/wix/WixToolset.Core/UnbindContext.cs29
-rw-r--r--src/wix/WixToolset.Core/Unbinder.cs99
-rw-r--r--src/wix/WixToolset.Core/WixToolsetServiceProvider.cs2
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/BundleExtractionFixture.cs4
13 files changed, 19 insertions, 215 deletions
diff --git a/src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs
deleted file mode 100644
index 6427422f..00000000
--- a/src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs
+++ /dev/null
@@ -1,24 +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
3namespace WixToolset.Extensibility.Data
4{
5 using System;
6
7#pragma warning disable 1591 // TODO: add documentation
8 public interface IUnbindContext
9 {
10 IServiceProvider ServiceProvider { get; }
11
12 string ExportBasePath { get; set; }
13
14 string InputFilePath { get; set; }
15
16 string IntermediateFolder { get; set; }
17
18 bool IsAdminImage { get; set; }
19
20 bool SuppressDemodularization { get; set; }
21
22 bool SuppressExtractCabinets { get; set; }
23 }
24} \ No newline at end of file
diff --git a/src/api/wix/WixToolset.Extensibility/IBackend.cs b/src/api/wix/WixToolset.Extensibility/IBackend.cs
index be8406e4..cb151e05 100644
--- a/src/api/wix/WixToolset.Extensibility/IBackend.cs
+++ b/src/api/wix/WixToolset.Extensibility/IBackend.cs
@@ -2,16 +2,21 @@
2 2
3namespace WixToolset.Extensibility 3namespace WixToolset.Extensibility
4{ 4{
5 using WixToolset.Data;
6 using WixToolset.Extensibility.Data; 5 using WixToolset.Extensibility.Data;
7 6
8#pragma warning disable 1591 // TODO: add documentation 7 /// <summary>
8 /// Interface all backends implement.
9 /// </summary>
9 public interface IBackend 10 public interface IBackend
10 { 11 {
12 /// <summary>
13 /// Bind the intermediate into the final output.
14 /// </summary>
15 /// <param name="context">Bind context.</param>
16 /// <returns>Result of the bind operation.</returns>
11 IBindResult Bind(IBindContext context); 17 IBindResult Bind(IBindContext context);
12 18
19#pragma warning disable 1591 // TODO: add documentation
13 IDecompileResult Decompile(IDecompileContext context); 20 IDecompileResult Decompile(IDecompileContext context);
14
15 Intermediate Unbind(IUnbindContext context);
16 } 21 }
17} 22}
diff --git a/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs b/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs
index 99a6704f..7f9ef62d 100644
--- a/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs
+++ b/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs
@@ -2,9 +2,18 @@
2 2
3namespace WixToolset.Extensibility 3namespace WixToolset.Extensibility
4{ 4{
5#pragma warning disable 1591 // TODO: add documentation 5 /// <summary>
6 /// Implemented by extensions to create backends.
7 /// </summary>
6 public interface IBackendFactory 8 public interface IBackendFactory
7 { 9 {
10 /// <summary>
11 /// Called to find the backend used to produce the requested output type.
12 /// </summary>
13 /// <param name="outputType">Type of output being created.</param>
14 /// <param name="outputPath">Path to the output to create.</param>
15 /// <param name="backend">The backend for the output.</param>
16 /// <returns>True if the backend was created, otherwise false.</returns>
8 bool TryCreateBackend(string outputType, string outputPath, out IBackend backend); 17 bool TryCreateBackend(string outputType, string outputPath, out IBackend backend);
9 } 18 }
10} 19}
diff --git a/src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs b/src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs
deleted file mode 100644
index 0e9a2504..00000000
--- a/src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs
+++ /dev/null
@@ -1,18 +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
3namespace WixToolset.Extensibility
4{
5 using System;
6 using WixToolset.Data;
7
8 /// <summary>
9 /// Base class for creating an unbinder extension.
10 /// </summary>
11 public interface IUnbinderExtension
12 {
13 /// <summary>
14 /// Called during the generation of sectionIds for an admin image.
15 /// </summary>
16 void GenerateSectionIds(Intermediate output);
17 }
18}
diff --git a/src/wix/WixToolset.Core.Burn/BundleBackend.cs b/src/wix/WixToolset.Core.Burn/BundleBackend.cs
index fa66ab1f..e248bc67 100644
--- a/src/wix/WixToolset.Core.Burn/BundleBackend.cs
+++ b/src/wix/WixToolset.Core.Burn/BundleBackend.cs
@@ -5,7 +5,6 @@ namespace WixToolset.Core.Burn
5 using System; 5 using System;
6 using System.IO; 6 using System.IO;
7 using WixToolset.Core.Burn.Bundles; 7 using WixToolset.Core.Burn.Bundles;
8 using WixToolset.Core.Burn.Inscribe;
9 using WixToolset.Data; 8 using WixToolset.Data;
10 using WixToolset.Extensibility; 9 using WixToolset.Extensibility;
11 using WixToolset.Extensibility.Data; 10 using WixToolset.Extensibility.Data;
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/MsiBackend.cs b/src/wix/WixToolset.Core.WindowsInstaller/MsiBackend.cs
index 628ad8de..d1c1d3a6 100644
--- a/src/wix/WixToolset.Core.WindowsInstaller/MsiBackend.cs
+++ b/src/wix/WixToolset.Core.WindowsInstaller/MsiBackend.cs
@@ -69,10 +69,5 @@ namespace WixToolset.Core.WindowsInstaller
69 69
70 return result; 70 return result;
71 } 71 }
72
73 public Intermediate Unbind(IUnbindContext context)
74 {
75 throw new NotImplementedException();
76 }
77 } 72 }
78} 73}
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/MsmBackend.cs b/src/wix/WixToolset.Core.WindowsInstaller/MsmBackend.cs
index 01e3c6d8..ea008c39 100644
--- a/src/wix/WixToolset.Core.WindowsInstaller/MsmBackend.cs
+++ b/src/wix/WixToolset.Core.WindowsInstaller/MsmBackend.cs
@@ -65,10 +65,5 @@ namespace WixToolset.Core.WindowsInstaller
65 65
66 return result; 66 return result;
67 } 67 }
68
69 public Intermediate Unbind(IUnbindContext context)
70 {
71 throw new NotImplementedException();
72 }
73 } 68 }
74} 69}
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs
index 82015cf2..8070d42d 100644
--- a/src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs
+++ b/src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs
@@ -7,7 +7,6 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
7 using WixToolset.Core.Native.Msi; 7 using WixToolset.Core.Native.Msi;
8 using WixToolset.Data; 8 using WixToolset.Data;
9 using WixToolset.Data.WindowsInstaller; 9 using WixToolset.Data.WindowsInstaller;
10 using WixToolset.Extensibility.Data;
11 using WixToolset.Extensibility.Services; 10 using WixToolset.Extensibility.Services;
12 11
13 internal class UnbindMsiOrMsmCommand 12 internal class UnbindMsiOrMsmCommand
@@ -24,16 +23,6 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
24 this.SuppressExtractCabinets = suppressExtractCabinets; 23 this.SuppressExtractCabinets = suppressExtractCabinets;
25 } 24 }
26 25
27 public UnbindMsiOrMsmCommand(IUnbindContext context)
28 {
29 this.Messaging = context.ServiceProvider.GetService<IMessaging>();
30 this.DatabasePath = context.InputFilePath;
31 this.ExportBasePath = context.ExportBasePath;
32 this.IntermediateFolder = context.IntermediateFolder;
33 this.IsAdminImage = context.IsAdminImage;
34 this.SuppressDemodularization = context.SuppressDemodularization;
35 }
36
37 private IMessaging Messaging { get; } 26 private IMessaging Messaging { get; }
38 27
39 private IBackendHelper BackendHelper { get; } 28 private IBackendHelper BackendHelper { get; }
diff --git a/src/wix/WixToolset.Core/IUnbinder.cs b/src/wix/WixToolset.Core/IUnbinder.cs
deleted file mode 100644
index 2b4daaa5..00000000
--- a/src/wix/WixToolset.Core/IUnbinder.cs
+++ /dev/null
@@ -1,12 +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
3namespace WixToolset.Core
4{
5 using WixToolset.Data;
6
7#pragma warning disable 1591 // TODO: add documentation, move into Extensibility
8 public interface IUnbinder
9 {
10 Intermediate Unbind(string file, OutputType outputType, string exportBasePath);
11 }
12}
diff --git a/src/wix/WixToolset.Core/UnbindContext.cs b/src/wix/WixToolset.Core/UnbindContext.cs
deleted file mode 100644
index c3817a08..00000000
--- a/src/wix/WixToolset.Core/UnbindContext.cs
+++ /dev/null
@@ -1,29 +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
3namespace WixToolset.Core
4{
5 using System;
6 using WixToolset.Extensibility.Data;
7
8 internal class UnbindContext : IUnbindContext
9 {
10 internal UnbindContext(IServiceProvider serviceProvider)
11 {
12 this.ServiceProvider = serviceProvider;
13 }
14
15 public IServiceProvider 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/wix/WixToolset.Core/Unbinder.cs b/src/wix/WixToolset.Core/Unbinder.cs
deleted file mode 100644
index 3ef77083..00000000
--- a/src/wix/WixToolset.Core/Unbinder.cs
+++ /dev/null
@@ -1,99 +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
3namespace WixToolset.Core
4{
5 using System;
6 using System.Collections.Generic;
7 using System.IO;
8 using WixToolset.Data;
9 using WixToolset.Extensibility;
10 using WixToolset.Extensibility.Services;
11
12 /// <summary>
13 /// Unbinder core of the WiX toolset.
14 /// </summary>
15 internal sealed class Unbinder : IUnbinder
16 {
17 public Unbinder(IServiceProvider serviceProvider)
18 {
19 this.ServiceProvider = serviceProvider;
20
21 var extensionManager = this.ServiceProvider.GetService<IExtensionManager>();
22 this.BackendFactories = extensionManager.GetServices<IBackendFactory>();
23 }
24
25 public IServiceProvider ServiceProvider { get; }
26
27 public IEnumerable<IBackendFactory> BackendFactories { get; }
28
29 /// <summary>
30 /// Gets or sets whether the input msi is an admin image.
31 /// </summary>
32 /// <value>Set to true if the input msi is part of an admin image.</value>
33 public bool IsAdminImage { get; set; }
34
35 /// <summary>
36 /// Gets or sets the option to suppress demodularizing values.
37 /// </summary>
38 /// <value>The option to suppress demodularizing values.</value>
39 public bool SuppressDemodularization { get; set; }
40
41 /// <summary>
42 /// Gets or sets the option to suppress extracting cabinets.
43 /// </summary>
44 /// <value>The option to suppress extracting cabinets.</value>
45 public bool SuppressExtractCabinets { get; set; }
46
47 /// <summary>
48 /// Gets or sets the temporary path for the Binder. If left null, the binder
49 /// will use %TEMP% environment variable.
50 /// </summary>
51 /// <value>Path to temp files.</value>
52 public string TempFilesLocation => Path.GetTempPath();
53
54 /// <summary>
55 /// Unbind a Windows Installer file.
56 /// </summary>
57 /// <param name="file">The Windows Installer file.</param>
58 /// <param name="outputType">The type of output to create.</param>
59 /// <param name="exportBasePath">The path where files should be exported.</param>
60 /// <returns>The output representing the database.</returns>
61 public Intermediate Unbind(string file, OutputType outputType, string exportBasePath)
62 {
63 if (!File.Exists(file))
64 {
65 if (OutputType.Transform == outputType)
66 {
67 throw new WixException(ErrorMessages.FileNotFound(null, file, "Transform"));
68 }
69 else
70 {
71 throw new WixException(ErrorMessages.FileNotFound(null, file, "Database"));
72 }
73 }
74
75 // if we don't have the temporary files object yet, get one
76 Directory.CreateDirectory(this.TempFilesLocation); // ensure the base path is there
77
78 var context = new UnbindContext(this.ServiceProvider);
79 context.InputFilePath = file;
80 context.ExportBasePath = exportBasePath;
81 context.IntermediateFolder = this.TempFilesLocation;
82 context.IsAdminImage = this.IsAdminImage;
83 context.SuppressDemodularization = this.SuppressDemodularization;
84 context.SuppressExtractCabinets = this.SuppressExtractCabinets;
85
86 foreach (var factory in this.BackendFactories)
87 {
88 if (factory.TryCreateBackend(outputType.ToString(), file, out var backend))
89 {
90 return backend.Unbind(context);
91 }
92 }
93
94 // TODO: Display message that could not find a unbinder for output type?
95
96 return null;
97 }
98 }
99}
diff --git a/src/wix/WixToolset.Core/WixToolsetServiceProvider.cs b/src/wix/WixToolset.Core/WixToolsetServiceProvider.cs
index 06dbdfae..a74ba6b3 100644
--- a/src/wix/WixToolset.Core/WixToolsetServiceProvider.cs
+++ b/src/wix/WixToolset.Core/WixToolsetServiceProvider.cs
@@ -41,7 +41,6 @@ namespace WixToolset.Core
41 this.AddService<IBindContext>((provider, singletons) => new BindContext(provider)); 41 this.AddService<IBindContext>((provider, singletons) => new BindContext(provider));
42 this.AddService<IDecompileContext>((provider, singletons) => new DecompileContext(provider)); 42 this.AddService<IDecompileContext>((provider, singletons) => new DecompileContext(provider));
43 this.AddService<ILayoutContext>((provider, singletons) => new LayoutContext(provider)); 43 this.AddService<ILayoutContext>((provider, singletons) => new LayoutContext(provider));
44 this.AddService<IUnbindContext>((provider, singletons) => new UnbindContext(provider));
45 44
46 this.AddService<IBindFileWithPath>((provider, singletons) => new BindFileWithPath()); 45 this.AddService<IBindFileWithPath>((provider, singletons) => new BindFileWithPath());
47 this.AddService<IBindPath>((provider, singletons) => new BindPath()); 46 this.AddService<IBindPath>((provider, singletons) => new BindPath());
@@ -64,7 +63,6 @@ namespace WixToolset.Core
64 this.AddService<ILibrarian>((provider, singletons) => new Librarian(provider)); 63 this.AddService<ILibrarian>((provider, singletons) => new Librarian(provider));
65 this.AddService<ILinker>((provider, singletons) => new Linker(provider)); 64 this.AddService<ILinker>((provider, singletons) => new Linker(provider));
66 this.AddService<IResolver>((provider, singletons) => new Resolver(provider)); 65 this.AddService<IResolver>((provider, singletons) => new Resolver(provider));
67 this.AddService<IUnbinder>((provider, singletons) => new Unbinder(provider));
68 66
69 this.AddService<ILocalizationParser>((provider, singletons) => new LocalizationParser(provider)); 67 this.AddService<ILocalizationParser>((provider, singletons) => new LocalizationParser(provider));
70 this.AddService<IVariableResolver>((provider, singletons) => new VariableResolver(provider)); 68 this.AddService<IVariableResolver>((provider, singletons) => new VariableResolver(provider));
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BundleExtractionFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BundleExtractionFixture.cs
index 0e056c29..5a5a52d3 100644
--- a/src/wix/test/WixToolsetTest.CoreIntegration/BundleExtractionFixture.cs
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/BundleExtractionFixture.cs
@@ -47,11 +47,7 @@ namespace WixToolsetTest.CoreIntegration
47 47
48 Assert.True(File.Exists(exePath)); 48 Assert.True(File.Exists(exePath));
49 49
50 var unbinder = serviceProvider.GetService<IUnbinder>();
51 unbinder.Unbind(exePath, OutputType.Bundle, extractFolderPath);
52 50
53 Assert.True(File.Exists(Path.Combine(baFolderPath, "manifest.xml")));
54 Assert.False(Directory.Exists(attachedContainerFolderPath));
55 } 51 }
56 } 52 }
57 } 53 }