Remove Unbind as backend function
Unbinding is not a general purpose function as initially imagined.
Rob Mensching committed
Mar 10, 2022 at 14:18 UTC
64750a8dd105d89c27613694e1008a454df2a4ee
13 files changed
+19
-215
src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs
deleted
-24
@@ -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
-
3
-namespace 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
src/api/wix/WixToolset.Extensibility/IBackend.cs
+9
-4
@@ -2,16 +2,21 @@
2
3
namespace WixToolset.Extensibility
4
{
5
- using WixToolset.Data;
5
using WixToolset.Extensibility.Data;
6
8
-#pragma warning disable 1591 // TODO: add documentation
7
+ /// <summary>
8
+ /// Interface all backends implement.
9
+ /// </summary>
10
public interface IBackend
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>
17
IBindResult Bind(IBindContext context);
18
19
+#pragma warning disable 1591 // TODO: add documentation
20
IDecompileResult Decompile(IDecompileContext context);
14
-
15
- Intermediate Unbind(IUnbindContext context);
21
}
22
}
src/api/wix/WixToolset.Extensibility/IBackendFactory.cs
+10
-1
@@ -2,9 +2,18 @@
2
3
namespace WixToolset.Extensibility
4
{
5
-#pragma warning disable 1591 // TODO: add documentation
5
+ /// <summary>
6
+ /// Implemented by extensions to create backends.
7
+ /// </summary>
8
public interface IBackendFactory
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>
17
bool TryCreateBackend(string outputType, string outputPath, out IBackend backend);
18
}
19
}
src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs
deleted
-18
@@ -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
-
3
-namespace 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
-}
src/wix/WixToolset.Core.Burn/BundleBackend.cs
-1
@@ -5,7 +5,6 @@ namespace WixToolset.Core.Burn
5
using System;
6
using System.IO;
7
using WixToolset.Core.Burn.Bundles;
8
- using WixToolset.Core.Burn.Inscribe;
8
using WixToolset.Data;
9
using WixToolset.Extensibility;
10
using WixToolset.Extensibility.Data;
src/wix/WixToolset.Core.WindowsInstaller/MsiBackend.cs
-5
@@ -69,10 +69,5 @@ namespace WixToolset.Core.WindowsInstaller
69
70
return result;
71
}
72
-
73
- public Intermediate Unbind(IUnbindContext context)
74
- {
75
- throw new NotImplementedException();
76
- }
72
}
73
}
src/wix/WixToolset.Core.WindowsInstaller/MsmBackend.cs
-5
@@ -65,10 +65,5 @@ namespace WixToolset.Core.WindowsInstaller
65
66
return result;
67
}
68
-
69
- public Intermediate Unbind(IUnbindContext context)
70
- {
71
- throw new NotImplementedException();
72
- }
68
}
69
}
src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindMsiOrMsmCommand.cs
-11
@@ -7,7 +7,6 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
7
using WixToolset.Core.Native.Msi;
8
using WixToolset.Data;
9
using WixToolset.Data.WindowsInstaller;
10
- using WixToolset.Extensibility.Data;
10
using WixToolset.Extensibility.Services;
11
12
internal class UnbindMsiOrMsmCommand
@@ -24,16 +23,6 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
23
this.SuppressExtractCabinets = suppressExtractCabinets;
24
}
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
-
26
private IMessaging Messaging { get; }
27
28
private IBackendHelper BackendHelper { get; }
src/wix/WixToolset.Core/IUnbinder.cs
deleted
-12
@@ -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
-
3
-namespace 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
-}
src/wix/WixToolset.Core/UnbindContext.cs
deleted
-29
@@ -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
-
3
-namespace 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
-}
src/wix/WixToolset.Core/Unbinder.cs
deleted
-99
@@ -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
-
3
-namespace 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
-}
src/wix/WixToolset.Core/WixToolsetServiceProvider.cs
-2
@@ -41,7 +41,6 @@ namespace WixToolset.Core
41
this.AddService<IBindContext>((provider, singletons) => new BindContext(provider));
42
this.AddService<IDecompileContext>((provider, singletons) => new DecompileContext(provider));
43
this.AddService<ILayoutContext>((provider, singletons) => new LayoutContext(provider));
44
- this.AddService<IUnbindContext>((provider, singletons) => new UnbindContext(provider));
44
45
this.AddService<IBindFileWithPath>((provider, singletons) => new BindFileWithPath());
46
this.AddService<IBindPath>((provider, singletons) => new BindPath());
@@ -64,7 +63,6 @@ namespace WixToolset.Core
63
this.AddService<ILibrarian>((provider, singletons) => new Librarian(provider));
64
this.AddService<ILinker>((provider, singletons) => new Linker(provider));
65
this.AddService<IResolver>((provider, singletons) => new Resolver(provider));
67
- this.AddService<IUnbinder>((provider, singletons) => new Unbinder(provider));
66
67
this.AddService<ILocalizationParser>((provider, singletons) => new LocalizationParser(provider));
68
this.AddService<IVariableResolver>((provider, singletons) => new VariableResolver(provider));
src/wix/test/WixToolsetTest.CoreIntegration/BundleExtractionFixture.cs
-4
@@ -47,11 +47,7 @@ namespace WixToolsetTest.CoreIntegration
47
48
Assert.True(File.Exists(exePath));
49
50
- var unbinder = serviceProvider.GetService<IUnbinder>();
51
- unbinder.Unbind(exePath, OutputType.Bundle, extractFolderPath);
50
53
- Assert.True(File.Exists(Path.Combine(baFolderPath, "manifest.xml")));
54
- Assert.False(Directory.Exists(attachedContainerFolderPath));
51
}
52
}
53
}