Integrate interface-only WixToolset.Extensibility change
Rob Mensching committed
Mar 1, 2019 at 11:12 UTC
5392cf57c09bddde7157e5b26c5c2a013f819ead
33 files changed
+427
-187
src/WixToolset.Core.Burn/BundleBackend.cs
+8
-3
@@ -9,10 +9,11 @@ namespace WixToolset.Core.Burn
9
using WixToolset.Data;
10
using WixToolset.Extensibility;
11
using WixToolset.Extensibility.Data;
12
+ using WixToolset.Extensibility.Services;
13
14
internal class BundleBackend : IBackend
15
{
15
- public BindResult Bind(IBindContext context)
16
+ public IBindResult Bind(IBindContext context)
17
{
18
BindBundleCommand command = new BindBundleCommand(context);
19
//command.DefaultCompressionLevel = context.DefaultCompressionLevel;
@@ -24,10 +25,14 @@ namespace WixToolset.Core.Burn
25
//command.WixVariableResolver = context.WixVariableResolver;
26
command.Execute();
27
27
- return new BindResult { FileTransfers = command.FileTransfers, TrackedFiles = command.TrackedFiles };
28
+ var result = context.ServiceProvider.GetService<IBindResult>();
29
+ result.FileTransfers = command.FileTransfers;
30
+ result.TrackedFiles = command.TrackedFiles;
31
+
32
+ return result;
33
}
34
30
- public DecompileResult Decompile(IDecompileContext context)
35
+ public IDecompileResult Decompile(IDecompileContext context)
36
{
37
throw new NotImplementedException();
38
}
src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+5
-1
@@ -24,6 +24,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind
24
25
public BindDatabaseCommand(IBindContext context, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtension, Validator validator)
26
{
27
+ this.ServiceProvider = context.ServiceProvider;
28
+
29
this.Messaging = context.ServiceProvider.GetService<IMessaging>();
30
31
this.BackendHelper = context.ServiceProvider.GetService<IBackendHelper>();
@@ -46,6 +48,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind
48
this.BackendExtensions = backendExtension;
49
}
50
51
+ public IServiceProvider ServiceProvider { get; }
52
+
53
private IMessaging Messaging { get; }
54
55
private IBackendHelper BackendHelper { get; }
@@ -383,7 +387,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
387
{
388
this.Messaging.Write(VerboseMessages.CreatingCabinetFiles());
389
386
- var command = new CreateCabinetsCommand(this.BackendHelper);
390
+ var command = new CreateCabinetsCommand(this.ServiceProvider, this.BackendHelper);
391
command.CabbingThreadCount = this.CabbingThreadCount;
392
command.CabCachePath = this.CabCachePath;
393
command.DefaultCompressionLevel = this.DefaultCompressionLevel;
src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs
+22
-6
@@ -1,4 +1,4 @@
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.
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.WindowsInstaller.Bind
4
{
@@ -11,25 +11,30 @@ namespace WixToolset.Core.WindowsInstaller.Bind
11
using WixToolset.Data;
12
using WixToolset.Extensibility;
13
using WixToolset.Extensibility.Data;
14
+ using WixToolset.Extensibility.Services;
15
16
public class CabinetResolver
17
{
17
- public CabinetResolver(string cabCachePath, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtensions)
18
+ public CabinetResolver(IServiceProvider serviceProvider, string cabCachePath, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtensions)
19
{
20
+ this.ServiceProvider = serviceProvider;
21
+
22
this.CabCachePath = cabCachePath;
23
24
this.BackendExtensions = backendExtensions;
25
}
26
27
+ private IServiceProvider ServiceProvider { get; }
28
+
29
private string CabCachePath { get; }
30
31
private IEnumerable<IWindowsInstallerBackendBinderExtension> BackendExtensions { get; }
32
28
- public ResolvedCabinet ResolveCabinet(string cabinetPath, IEnumerable<FileFacade> fileFacades)
33
+ public IResolvedCabinet ResolveCabinet(string cabinetPath, IEnumerable<FileFacade> fileFacades)
34
{
30
- var filesWithPath = fileFacades.Select(f => new BindFileWithPath() { Id = f.File.File, Path = f.WixFile.Source.Path }).ToList();
35
+ var filesWithPath = fileFacades.Select(this.CreateBindFileWithPath).ToList();
36
32
- ResolvedCabinet resolved = null;
37
+ IResolvedCabinet resolved = null;
38
39
foreach (var extension in this.BackendExtensions)
40
{
@@ -42,7 +47,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind
47
}
48
49
// By default cabinet should be built and moved to the suggested location.
45
- resolved = new ResolvedCabinet() { BuildOption = CabinetBuildOption.BuildAndMove, Path = cabinetPath };
50
+ resolved = this.ServiceProvider.GetService<IResolvedCabinet>();
51
+ resolved.BuildOption = CabinetBuildOption.BuildAndMove;
52
+ resolved.Path = cabinetPath;
53
54
// If a cabinet cache path was provided, change the location for the cabinet
55
// to be built to and check if there is a cabinet that can be reused.
@@ -102,6 +109,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind
109
return resolved;
110
}
111
112
+ private IBindFileWithPath CreateBindFileWithPath(FileFacade facade)
113
+ {
114
+ var result = this.ServiceProvider.GetService<IBindFileWithPath>();
115
+ result.Id = facade.File.File;
116
+ result.Path = facade.WixFile.Source.Path;
117
+
118
+ return result;
119
+ }
120
+
121
private static bool CheckFileExists(string path)
122
{
123
try
src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs
+6
-2
@@ -34,7 +34,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
34
35
private Dictionary<string, string> lastCabinetAddedToMediaTable; // Key is First Cabinet Name, Value is Last Cabinet Added in the Split Sequence
36
37
- public CreateCabinetsCommand(IBackendHelper backendHelper)
37
+ public CreateCabinetsCommand(IServiceProvider serviceProvider, IBackendHelper backendHelper)
38
{
39
this.fileTransfers = new List<IFileTransfer>();
40
@@ -42,9 +42,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind
42
43
this.newCabNamesCallBack = this.NewCabNamesCallBack;
44
45
+ this.ServiceProvider = serviceProvider;
46
+
47
this.BackendHelper = backendHelper;
48
}
49
50
+ public IServiceProvider ServiceProvider { get; }
51
+
52
public IBackendHelper BackendHelper { get; }
53
54
/// <summary>
@@ -221,7 +225,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
225
}
226
}
227
224
- var cabinetResolver = new CabinetResolver(this.CabCachePath, this.BackendExtensions);
228
+ var cabinetResolver = new CabinetResolver(this.ServiceProvider, this.CabCachePath, this.BackendExtensions);
229
230
var resolvedCabinet = cabinetResolver.ResolveCabinet(tempCabinetFileX, fileFacades);
231
src/WixToolset.Core.WindowsInstaller/Decompile/DecompileMsiOrMsmCommand.cs
+2
-2
@@ -28,9 +28,9 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
28
29
private IMessaging Messaging { get; }
30
31
- public DecompileResult Execute()
31
+ public IDecompileResult Execute()
32
{
33
- var result = new DecompileResult();
33
+ var result = this.Context.ServiceProvider.GetService<IDecompileResult>();
34
35
try
36
{
src/WixToolset.Core.WindowsInstaller/MsiBackend.cs
+5
-3
@@ -13,7 +13,7 @@ namespace WixToolset.Core.WindowsInstaller
13
14
internal class MsiBackend : IBackend
15
{
16
- public BindResult Bind(IBindContext context)
16
+ public IBindResult Bind(IBindContext context)
17
{
18
var extensionManager = context.ServiceProvider.GetService<IExtensionManager>();
19
@@ -29,7 +29,9 @@ namespace WixToolset.Core.WindowsInstaller
29
var command = new BindDatabaseCommand(context, backendExtensions, validator);
30
command.Execute();
31
32
- var result = new BindResult { FileTransfers = command.FileTransfers, TrackedFiles = command.TrackedFiles };
32
+ var result = context.ServiceProvider.GetService<IBindResult>();
33
+ result.FileTransfers = command.FileTransfers;
34
+ result.TrackedFiles = command.TrackedFiles;
35
36
foreach (var extension in backendExtensions)
37
{
@@ -38,7 +40,7 @@ namespace WixToolset.Core.WindowsInstaller
40
return result;
41
}
42
41
- public DecompileResult Decompile(IDecompileContext context)
43
+ public IDecompileResult Decompile(IDecompileContext context)
44
{
45
var extensionManager = context.ServiceProvider.GetService<IExtensionManager>();
46
src/WixToolset.Core.WindowsInstaller/MsmBackend.cs
+5
-3
@@ -12,7 +12,7 @@ namespace WixToolset.Core.WindowsInstaller
12
13
internal class MsmBackend : IBackend
14
{
15
- public BindResult Bind(IBindContext context)
15
+ public IBindResult Bind(IBindContext context)
16
{
17
var extensionManager = context.ServiceProvider.GetService<IExtensionManager>();
18
@@ -28,7 +28,9 @@ namespace WixToolset.Core.WindowsInstaller
28
var command = new BindDatabaseCommand(context, backendExtensions, validator);
29
command.Execute();
30
31
- var result = new BindResult { FileTransfers = command.FileTransfers, TrackedFiles = command.TrackedFiles };
31
+ var result = context.ServiceProvider.GetService<IBindResult>();
32
+ result.FileTransfers = command.FileTransfers;
33
+ result.TrackedFiles = command.TrackedFiles;
34
35
foreach (var extension in backendExtensions)
36
{
@@ -43,7 +45,7 @@ namespace WixToolset.Core.WindowsInstaller
45
return result;
46
}
47
46
- public DecompileResult Decompile(IDecompileContext context)
48
+ public IDecompileResult Decompile(IDecompileContext context)
49
{
50
var extensionManager = context.ServiceProvider.GetService<IExtensionManager>();
51
src/WixToolset.Core.WindowsInstaller/MspBackend.cs
+2
-2
@@ -16,12 +16,12 @@ namespace WixToolset.Core.WindowsInstaller
16
17
internal class MspBackend : IBackend
18
{
19
- public BindResult Bind(IBindContext context)
19
+ public IBindResult Bind(IBindContext context)
20
{
21
throw new NotImplementedException();
22
}
23
24
- public DecompileResult Decompile(IDecompileContext context)
24
+ public IDecompileResult Decompile(IDecompileContext context)
25
{
26
throw new NotImplementedException();
27
}
src/WixToolset.Core.WindowsInstaller/MstBackend.cs
+2
-2
@@ -10,7 +10,7 @@ namespace WixToolset.Core.WindowsInstaller
10
11
internal class MstBackend : IBackend
12
{
13
- public BindResult Bind(IBindContext context)
13
+ public IBindResult Bind(IBindContext context)
14
{
15
#if REVISIT_FOR_PATCHING
16
var command = new BindTransformCommand();
@@ -25,7 +25,7 @@ namespace WixToolset.Core.WindowsInstaller
25
throw new NotImplementedException();
26
}
27
28
- public DecompileResult Decompile(IDecompileContext context)
28
+ public IDecompileResult Decompile(IDecompileContext context)
29
{
30
throw new NotImplementedException();
31
}
src/WixToolset.Core/Bind/FileResolver.cs
+6
-6
@@ -1,4 +1,4 @@
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.
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.Bind
4
{
@@ -14,24 +14,24 @@ namespace WixToolset.Core.Bind
14
{
15
private const string BindPathOpenString = "!(bindpath.";
16
17
- private FileResolver(IEnumerable<BindPath> bindPaths)
17
+ private FileResolver(IEnumerable<IBindPath> bindPaths)
18
{
19
- this.BindPaths = (bindPaths ?? Array.Empty<BindPath>()).ToLookup(b => b.Stage);
19
+ this.BindPaths = (bindPaths ?? Array.Empty<IBindPath>()).ToLookup(b => b.Stage);
20
this.RebaseTarget = this.BindPaths[BindStage.Target].Any();
21
this.RebaseUpdated = this.BindPaths[BindStage.Updated].Any();
22
}
23
24
- public FileResolver(IEnumerable<BindPath> bindPaths, IEnumerable<IResolverExtension> extensions) : this(bindPaths)
24
+ public FileResolver(IEnumerable<IBindPath> bindPaths, IEnumerable<IResolverExtension> extensions) : this(bindPaths)
25
{
26
this.ResolverExtensions = extensions ?? Array.Empty<IResolverExtension>();
27
}
28
29
- public FileResolver(IEnumerable<BindPath> bindPaths, IEnumerable<ILibrarianExtension> extensions) : this(bindPaths)
29
+ public FileResolver(IEnumerable<IBindPath> bindPaths, IEnumerable<ILibrarianExtension> extensions) : this(bindPaths)
30
{
31
this.LibrarianExtensions = extensions ?? Array.Empty<ILibrarianExtension>();
32
}
33
34
- private ILookup<BindStage, BindPath> BindPaths { get; }
34
+ private ILookup<BindStage, IBindPath> BindPaths { get; }
35
36
public bool RebaseTarget { get; }
37
src/WixToolset.Core/Bind/ResolveFieldsCommand.cs
+1
-1
@@ -20,7 +20,7 @@ namespace WixToolset.Core.Bind
20
21
public IVariableResolver VariableResolver { private get; set; }
22
23
- public IEnumerable<BindPath> BindPaths { private get; set; }
23
+ public IEnumerable<IBindPath> BindPaths { private get; set; }
24
25
public IEnumerable<IResolverExtension> Extensions { private get; set; }
26
src/WixToolset.Core/BindFileWithPath.cs
new
+22
@@ -0,0 +1,22 @@
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.Extensibility.Data;
6
+
7
+ /// <summary>
8
+ /// Bind file with its path.
9
+ /// </summary>
10
+ internal class BindFileWithPath : IBindFileWithPath
11
+ {
12
+ /// <summary>
13
+ /// Gets or sets the identifier of the file with this path.
14
+ /// </summary>
15
+ public string Id { get; set; }
16
+
17
+ /// <summary>
18
+ /// Gets or sets the file path.
19
+ /// </summary>
20
+ public string Path { get; set; }
21
+ }
22
+}
src/WixToolset.Core/BindPath.cs
new
+18
@@ -0,0 +1,18 @@
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.Extensibility.Data;
6
+
7
+ /// <summary>
8
+ /// Bind path representation.
9
+ /// </summary>
10
+ internal class BindPath : IBindPath
11
+ {
12
+ public string Name { get; set; }
13
+
14
+ public string Path { get; set; }
15
+
16
+ public BindStage Stage { get; set; }
17
+ }
18
+}
src/WixToolset.Core/BindResult.cs
new
+14
@@ -0,0 +1,14 @@
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.Generic;
6
+ using WixToolset.Extensibility.Data;
7
+
8
+ internal class BindResult : IBindResult
9
+ {
10
+ public IEnumerable<IFileTransfer> FileTransfers { get; set; }
11
+
12
+ public IEnumerable<ITrackedFile> TrackedFiles { get; set; }
13
+ }
14
+}
src/WixToolset.Core/Binder.cs
+2
-2
@@ -24,7 +24,7 @@ namespace WixToolset.Core
24
25
public IServiceProvider ServiceProvider { get; }
26
27
- public BindResult Bind(IBindContext context)
27
+ public IBindResult Bind(IBindContext context)
28
{
29
// Prebind.
30
//
@@ -52,7 +52,7 @@ namespace WixToolset.Core
52
return bindResult;
53
}
54
55
- private BindResult BackendBind(IBindContext context)
55
+ private IBindResult BackendBind(IBindContext context)
56
{
57
var extensionManager = context.ServiceProvider.GetService<IExtensionManager>();
58
src/WixToolset.Core/CommandLine/BuildCommand.cs
+144
-131
@@ -21,7 +21,7 @@ namespace WixToolset.Core.CommandLine
21
this.ServiceProvider = serviceProvider;
22
this.Messaging = serviceProvider.GetService<IMessaging>();
23
this.ExtensionManager = serviceProvider.GetService<IExtensionManager>();
24
- this.commandLine = new CommandLine(this.Messaging);
24
+ this.commandLine = new CommandLine(this.ServiceProvider, this.Messaging);
25
}
26
27
public bool ShowLogo => this.commandLine.ShowLogo;
@@ -214,7 +214,7 @@ namespace WixToolset.Core.CommandLine
214
return intermediates;
215
}
216
217
- private Intermediate LibraryPhase(IEnumerable<Intermediate> intermediates, IEnumerable<Localization> localizations, bool bindFiles, IEnumerable<BindPath> bindPaths)
217
+ private Intermediate LibraryPhase(IEnumerable<Intermediate> intermediates, IEnumerable<Localization> localizations, bool bindFiles, IEnumerable<IBindPath> bindPaths)
218
{
219
var context = this.ServiceProvider.GetService<ILibraryContext>();
220
context.BindFiles = bindFiles;
@@ -257,7 +257,7 @@ namespace WixToolset.Core.CommandLine
257
return linker.Link(context);
258
}
259
260
- private void BindPhase(Intermediate output, IEnumerable<Localization> localizations, IEnumerable<string> filterCultures, string cabCachePath, IEnumerable<BindPath> bindPaths)
260
+ private void BindPhase(Intermediate output, IEnumerable<Localization> localizations, IEnumerable<string> filterCultures, string cabCachePath, IEnumerable<IBindPath> bindPaths)
261
{
262
var intermediateFolder = this.IntermediateFolder;
263
if (String.IsNullOrEmpty(intermediateFolder))
@@ -265,7 +265,7 @@ namespace WixToolset.Core.CommandLine
265
intermediateFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
266
}
267
268
- ResolveResult resolveResult;
268
+ IResolveResult resolveResult;
269
{
270
var context = this.ServiceProvider.GetService<IResolveContext>();
271
context.BindPaths = bindPaths;
@@ -286,7 +286,7 @@ namespace WixToolset.Core.CommandLine
286
return;
287
}
288
289
- BindResult bindResult;
289
+ IBindResult bindResult;
290
{
291
var context = this.ServiceProvider.GetService<IBindContext>();
292
//context.CabbingThreadCount = this.CabbingThreadCount;
@@ -397,7 +397,7 @@ namespace WixToolset.Core.CommandLine
397
398
public bool BindFiles { get; private set; }
399
400
- public List<BindPath> BindPaths { get; } = new List<BindPath>();
400
+ public List<IBindPath> BindPaths { get; } = new List<IBindPath>();
401
402
public string CabCachePath { get; private set; }
403
@@ -431,11 +431,14 @@ namespace WixToolset.Core.CommandLine
431
432
public string BuiltOutputsFile { get; private set; }
433
434
- public CommandLine(IMessaging messaging)
434
+ public CommandLine(IServiceProvider serviceProvider, IMessaging messaging)
435
{
436
+ this.ServiceProvider = serviceProvider;
437
this.Messaging = messaging;
438
}
439
440
+ private IServiceProvider ServiceProvider { get; }
441
+
442
private IMessaging Messaging { get; }
443
444
public bool TryParseArgument(string arg, ICommandLineParser parser)
@@ -445,109 +448,109 @@ namespace WixToolset.Core.CommandLine
448
var parameter = arg.Substring(1);
449
switch (parameter.ToLowerInvariant())
450
{
448
- case "?":
449
- case "h":
450
- case "help":
451
- this.ShowHelp = true;
452
- return true;
453
-
454
- case "arch":
455
- case "platform":
456
- {
457
- var value = parser.GetNextArgumentOrError(arg);
458
- if (Enum.TryParse(value, true, out Platform platform))
459
- {
460
- this.Platform = platform;
451
+ case "?":
452
+ case "h":
453
+ case "help":
454
+ this.ShowHelp = true;
455
return true;
462
- }
463
- break;
464
- }
465
-
466
- case "bindfiles":
467
- this.BindFiles = true;
468
- return true;
456
470
- case "bindpath":
471
- {
472
- var value = parser.GetNextArgumentOrError(arg);
473
- if (this.TryParseBindPath(value, out var bindPath))
457
+ case "arch":
458
+ case "platform":
459
{
475
- this.BindPaths.Add(bindPath);
476
- return true;
460
+ var value = parser.GetNextArgumentOrError(arg);
461
+ if (Enum.TryParse(value, true, out Platform platform))
462
+ {
463
+ this.Platform = platform;
464
+ return true;
465
+ }
466
+ break;
467
}
478
- break;
479
- }
480
- case "cc":
481
- this.CabCachePath = parser.GetNextArgumentOrError(arg);
482
- return true;
483
-
484
- case "culture":
485
- parser.GetNextArgumentOrError(arg, this.Cultures);
486
- return true;
487
-
488
- case "contentsfile":
489
- this.ContentsFile = parser.GetNextArgumentAsFilePathOrError(arg);
490
- return true;
491
- case "outputsfile":
492
- this.OutputsFile = parser.GetNextArgumentAsFilePathOrError(arg);
493
- return true;
494
- case "builtoutputsfile":
495
- this.BuiltOutputsFile = parser.GetNextArgumentAsFilePathOrError(arg);
496
- return true;
497
-
498
- case "d":
499
- case "define":
500
- parser.GetNextArgumentOrError(arg, this.Defines);
501
- return true;
502
-
503
- case "i":
504
- case "includepath":
505
- parser.GetNextArgumentOrError(arg, this.IncludeSearchPaths);
506
- return true;
507
-
508
- case "intermediatefolder":
509
- this.IntermediateFolder = parser.GetNextArgumentAsDirectoryOrError(arg);
510
- return true;
511
-
512
- case "loc":
513
- parser.GetNextArgumentAsFilePathOrError(arg, "localization files", this.LocalizationFilePaths);
514
- return true;
515
-
516
- case "lib":
517
- parser.GetNextArgumentAsFilePathOrError(arg, "library files", this.LibraryFilePaths);
518
- return true;
519
-
520
- case "o":
521
- case "out":
522
- this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg);
523
- return true;
524
-
525
- case "outputtype":
526
- this.OutputType = parser.GetNextArgumentOrError(arg);
527
- return true;
528
-
529
- case "nologo":
530
- this.ShowLogo = false;
531
- return true;
532
-
533
- case "v":
534
- case "verbose":
535
- this.Messaging.ShowVerboseMessages = true;
536
- return true;
537
-
538
- case "sval":
539
- // todo: implement
540
- return true;
541
-
542
- case "sw":
543
- case "suppresswarning":
544
- var warning = parser.GetNextArgumentOrError(arg);
545
- if (!String.IsNullOrEmpty(warning))
468
+
469
+ case "bindfiles":
470
+ this.BindFiles = true;
471
+ return true;
472
+
473
+ case "bindpath":
474
{
547
- var warningNumber = Convert.ToInt32(warning);
548
- this.Messaging.SuppressWarningMessage(warningNumber);
475
+ var value = parser.GetNextArgumentOrError(arg);
476
+ if (this.TryParseBindPath(value, out var bindPath))
477
+ {
478
+ this.BindPaths.Add(bindPath);
479
+ return true;
480
+ }
481
+ break;
482
}
550
- return true;
483
+ case "cc":
484
+ this.CabCachePath = parser.GetNextArgumentOrError(arg);
485
+ return true;
486
+
487
+ case "culture":
488
+ parser.GetNextArgumentOrError(arg, this.Cultures);
489
+ return true;
490
+
491
+ case "contentsfile":
492
+ this.ContentsFile = parser.GetNextArgumentAsFilePathOrError(arg);
493
+ return true;
494
+ case "outputsfile":
495
+ this.OutputsFile = parser.GetNextArgumentAsFilePathOrError(arg);
496
+ return true;
497
+ case "builtoutputsfile":
498
+ this.BuiltOutputsFile = parser.GetNextArgumentAsFilePathOrError(arg);
499
+ return true;
500
+
501
+ case "d":
502
+ case "define":
503
+ parser.GetNextArgumentOrError(arg, this.Defines);
504
+ return true;
505
+
506
+ case "i":
507
+ case "includepath":
508
+ parser.GetNextArgumentOrError(arg, this.IncludeSearchPaths);
509
+ return true;
510
+
511
+ case "intermediatefolder":
512
+ this.IntermediateFolder = parser.GetNextArgumentAsDirectoryOrError(arg);
513
+ return true;
514
+
515
+ case "loc":
516
+ parser.GetNextArgumentAsFilePathOrError(arg, "localization files", this.LocalizationFilePaths);
517
+ return true;
518
+
519
+ case "lib":
520
+ parser.GetNextArgumentAsFilePathOrError(arg, "library files", this.LibraryFilePaths);
521
+ return true;
522
+
523
+ case "o":
524
+ case "out":
525
+ this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg);
526
+ return true;
527
+
528
+ case "outputtype":
529
+ this.OutputType = parser.GetNextArgumentOrError(arg);
530
+ return true;
531
+
532
+ case "nologo":
533
+ this.ShowLogo = false;
534
+ return true;
535
+
536
+ case "v":
537
+ case "verbose":
538
+ this.Messaging.ShowVerboseMessages = true;
539
+ return true;
540
+
541
+ case "sval":
542
+ // todo: implement
543
+ return true;
544
+
545
+ case "sw":
546
+ case "suppresswarning":
547
+ var warning = parser.GetNextArgumentOrError(arg);
548
+ if (!String.IsNullOrEmpty(warning))
549
+ {
550
+ var warningNumber = Convert.ToInt32(warning);
551
+ this.Messaging.SuppressWarningMessage(warningNumber);
552
+ }
553
+ return true;
554
}
555
556
return false;
@@ -573,37 +576,37 @@ namespace WixToolset.Core.CommandLine
576
577
switch (this.OutputType.ToLowerInvariant())
578
{
576
- case "bundle":
577
- case ".exe":
578
- return Data.OutputType.Bundle;
579
+ case "bundle":
580
+ case ".exe":
581
+ return Data.OutputType.Bundle;
582
580
- case "library":
581
- case ".wixlib":
582
- return Data.OutputType.Library;
583
+ case "library":
584
+ case ".wixlib":
585
+ return Data.OutputType.Library;
586
584
- case "module":
585
- case ".msm":
586
- return Data.OutputType.Module;
587
+ case "module":
588
+ case ".msm":
589
+ return Data.OutputType.Module;
590
588
- case "patch":
589
- case ".msp":
590
- return Data.OutputType.Patch;
591
+ case "patch":
592
+ case ".msp":
593
+ return Data.OutputType.Patch;
594
592
- case ".pcp":
593
- return Data.OutputType.PatchCreation;
595
+ case ".pcp":
596
+ return Data.OutputType.PatchCreation;
597
595
- case "product":
596
- case "package":
597
- case ".msi":
598
- return Data.OutputType.Product;
598
+ case "product":
599
+ case "package":
600
+ case ".msi":
601
+ return Data.OutputType.Product;
602
600
- case "transform":
601
- case ".mst":
602
- return Data.OutputType.Transform;
603
+ case "transform":
604
+ case ".mst":
605
+ return Data.OutputType.Transform;
606
604
- case "intermediatepostlink":
605
- case ".wixipl":
606
- return Data.OutputType.IntermediatePostLink;
607
+ case "intermediatepostlink":
608
+ case ".wixipl":
609
+ return Data.OutputType.IntermediatePostLink;
610
}
611
612
return Data.OutputType.Unknown;
@@ -656,7 +659,6 @@ namespace WixToolset.Core.CommandLine
659
return variables;
660
}
661
659
-
662
public IEnumerable<SourceFile> GatherSourceFiles(string intermediateDirectory)
663
{
664
var files = new List<SourceFile>();
@@ -672,10 +674,21 @@ namespace WixToolset.Core.CommandLine
674
return files;
675
}
676
675
- private bool TryParseBindPath(string bindPath, out BindPath bp)
677
+ private bool TryParseBindPath(string bindPath, out IBindPath bp)
678
{
679
var namedPath = bindPath.Split(BindPathSplit, 2);
678
- bp = (1 == namedPath.Length) ? new BindPath(namedPath[0]) : new BindPath(namedPath[0], namedPath[1]);
680
+
681
+ bp = this.ServiceProvider.GetService<IBindPath>();
682
+
683
+ if (1 == namedPath.Length)
684
+ {
685
+ bp.Path = namedPath[0];
686
+ }
687
+ else
688
+ {
689
+ bp.Name = namedPath[0];
690
+ bp.Path = namedPath[1];
691
+ }
692
693
if (File.Exists(bp.Path))
694
{
src/WixToolset.Core/CompilerCore.cs
+3
-3
@@ -534,7 +534,7 @@ namespace WixToolset.Core
534
string value = this.GetAttributeValue(sourceLineNumbers, attribute);
535
536
// allow for localization of code page names and values
537
- if (IsValidLocIdentifier(value))
537
+ if (this.IsValidLocIdentifier(value))
538
{
539
return value;
540
}
@@ -648,7 +648,7 @@ namespace WixToolset.Core
648
649
if (0 < value.Length)
650
{
651
- if (IsValidLocIdentifier(value) || Common.IsValidBinderVariable(value))
651
+ if (this.IsValidLocIdentifier(value) || Common.IsValidBinderVariable(value))
652
{
653
return value;
654
}
@@ -1010,7 +1010,7 @@ namespace WixToolset.Core
1010
/// <param name="parentElement">Element containing element to be parsed.</param>
1011
/// <param name="element">Element to be parsed.</param>
1012
/// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
1013
- public ComponentKeyPath ParsePossibleKeyPathExtensionElement(XElement parentElement, XElement element, IDictionary<string, string> context)
1013
+ public IComponentKeyPath ParsePossibleKeyPathExtensionElement(XElement parentElement, XElement element, IDictionary<string, string> context)
1014
{
1015
return this.parseHelper.ParsePossibleKeyPathExtensionElement(this.extensions.Values, this.intermediate, this.ActiveSection, parentElement, element, context);
1016
}
src/WixToolset.Core/ComponentKeyPath.cs
new
+24
@@ -0,0 +1,24 @@
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.Extensibility.Data;
6
+
7
+ internal class ComponentKeyPath : IComponentKeyPath
8
+ {
9
+ /// <summary>
10
+ /// Identifier of the resource to be a key path.
11
+ /// </summary>
12
+ public string Id { get; set; }
13
+
14
+ /// <summary>
15
+ /// Indicates whether the key path was explicitly set for this resource.
16
+ /// </summary>
17
+ public bool Explicit { get; set; }
18
+
19
+ /// <summary>
20
+ /// Type of resource to be the key path.
21
+ /// </summary>
22
+ public ComponentKeyPathType Type { get; set; }
23
+ }
24
+}
src/WixToolset.Core/DecompileResult.cs
new
+15
@@ -0,0 +1,15 @@
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.Generic;
6
+ using System.Xml.Linq;
7
+ using WixToolset.Extensibility.Data;
8
+
9
+ internal class DecompileResult : IDecompileResult
10
+ {
11
+ public XDocument Document { get; set; }
12
+
13
+ public IEnumerable<string> ExtractedFilePaths { get; set; }
14
+ }
15
+}
src/WixToolset.Core/Decompiler.cs
+2
-2
@@ -19,7 +19,7 @@ namespace WixToolset.Core
19
20
public IServiceProvider ServiceProvider { get; }
21
22
- public DecompileResult Decompile(IDecompileContext context)
22
+ public IDecompileResult Decompile(IDecompileContext context)
23
{
24
// Pre-decompile.
25
//
@@ -45,7 +45,7 @@ namespace WixToolset.Core
45
return result;
46
}
47
48
- private DecompileResult BackendDecompile(IDecompileContext context)
48
+ private IDecompileResult BackendDecompile(IDecompileContext context)
49
{
50
var extensionManager = context.ServiceProvider.GetService<IExtensionManager>();
51
src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
+3
-3
@@ -1,4 +1,4 @@
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.
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.ExtensibilityServices
4
{
@@ -777,9 +777,9 @@ namespace WixToolset.Core.ExtensibilityServices
777
}
778
}
779
780
- public ComponentKeyPath ParsePossibleKeyPathExtensionElement(IEnumerable<ICompilerExtension> extensions, Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context)
780
+ public IComponentKeyPath ParsePossibleKeyPathExtensionElement(IEnumerable<ICompilerExtension> extensions, Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context)
781
{
782
- ComponentKeyPath keyPath = null;
782
+ IComponentKeyPath keyPath = null;
783
784
if (ParseHelper.TryFindExtension(extensions, element.Name.Namespace, out var extension))
785
{
src/WixToolset.Core/IBinder.cs
+2
-2
@@ -1,4 +1,4 @@
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.
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
{
@@ -6,6 +6,6 @@ namespace WixToolset.Core
6
7
public interface IBinder
8
{
9
- BindResult Bind(IBindContext context);
9
+ IBindResult Bind(IBindContext context);
10
}
11
}
src/WixToolset.Core/IDecompiler.cs
+1
-1
@@ -6,6 +6,6 @@ namespace WixToolset.Core
6
7
public interface IDecompiler
8
{
9
- DecompileResult Decompile(IDecompileContext context);
9
+ IDecompileResult Decompile(IDecompileContext context);
10
}
11
}
src/WixToolset.Core/IResolver.cs
+2
-2
@@ -1,4 +1,4 @@
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.
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
{
@@ -6,6 +6,6 @@ namespace WixToolset.Core
6
7
public interface IResolver
8
{
9
- ResolveResult Resolve(IResolveContext context);
9
+ IResolveResult Resolve(IResolveContext context);
10
}
11
}
src/WixToolset.Core/LibraryContext.cs
+2
-2
@@ -1,4 +1,4 @@
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.
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
{
@@ -22,7 +22,7 @@ namespace WixToolset.Core
22
23
public bool BindFiles { get; set; }
24
25
- public IEnumerable<BindPath> BindPaths { get; set; }
25
+ public IEnumerable<IBindPath> BindPaths { get; set; }
26
27
public IEnumerable<ILibrarianExtension> Extensions { get; set; }
28
src/WixToolset.Core/ResolveContext.cs
+2
-2
@@ -1,4 +1,4 @@
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.
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
{
@@ -18,7 +18,7 @@ namespace WixToolset.Core
18
19
public IServiceProvider ServiceProvider { get; }
20
21
- public IEnumerable<BindPath> BindPaths { get; set; }
21
+ public IEnumerable<IBindPath> BindPaths { get; set; }
22
23
public IEnumerable<IResolverExtension> Extensions { get; set; }
24
src/WixToolset.Core/ResolveFileResult.cs
new
+14
@@ -0,0 +1,14 @@
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.Generic;
6
+ using WixToolset.Extensibility.Data;
7
+
8
+ public class ResolveFileResult : IResolveFileResult
9
+ {
10
+ public string Path { get; set; }
11
+
12
+ public IEnumerable<string> CheckedPaths { get; set; }
13
+ }
14
+}
src/WixToolset.Core/ResolveResult.cs
new
+19
@@ -0,0 +1,19 @@
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.Generic;
6
+ using WixToolset.Data;
7
+ using WixToolset.Extensibility.Data;
8
+
9
+ internal class ResolveResult : IResolveResult
10
+ {
11
+ public int Codepage { get; set; }
12
+
13
+ public IEnumerable<IDelayedField> DelayedFields { get; set; }
14
+
15
+ public IEnumerable<IExpectedExtractFile> ExpectedEmbeddedFiles { get; set; }
16
+
17
+ public Intermediate IntermediateRepresentation { get; set; }
18
+ }
19
+}
src/WixToolset.Core/ResolvedCabinet.cs
new
+22
@@ -0,0 +1,22 @@
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.Extensibility.Data;
6
+
7
+ /// <summary>
8
+ /// Data returned from build file manager ResolveCabinet callback.
9
+ /// </summary>
10
+ public class ResolvedCabinet : IResolvedCabinet
11
+ {
12
+ /// <summary>
13
+ /// Gets or sets the build option for the resolved cabinet.
14
+ /// </summary>
15
+ public CabinetBuildOption BuildOption { get; set; }
16
+
17
+ /// <summary>
18
+ /// Gets or sets the path for the resolved cabinet.
19
+ /// </summary>
20
+ public string Path { get; set; }
21
+ }
22
+}
src/WixToolset.Core/Resolver.cs
+2
-2
@@ -28,7 +28,7 @@ namespace WixToolset.Core
28
29
private IMessaging Messaging { get; }
30
31
- public IEnumerable<BindPath> BindPaths { get; set; }
31
+ public IEnumerable<IBindPath> BindPaths { get; set; }
32
33
public string IntermediateFolder { get; set; }
34
@@ -38,7 +38,7 @@ namespace WixToolset.Core
38
39
public IEnumerable<string> FilterCultures { get; set; }
40
41
- public ResolveResult Resolve(IResolveContext context)
41
+ public IResolveResult Resolve(IResolveContext context)
42
{
43
44
foreach (var extension in context.Extensions)
src/WixToolset.Core/VariableResolution.cs
new
+29
@@ -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
+
3
+namespace WixToolset.Core
4
+{
5
+ using WixToolset.Extensibility.Services;
6
+
7
+ internal class VariableResolution : IVariableResolution
8
+ {
9
+ /// <summary>
10
+ /// Indicates whether the variable should be delay resolved.
11
+ /// </summary>
12
+ public bool DelayedResolve { get; set; }
13
+
14
+ /// <summary>
15
+ /// Indicates whether the value is the default value of the variable.
16
+ /// </summary>
17
+ public bool IsDefault { get; set; }
18
+
19
+ /// <summary>
20
+ /// Indicates whether the value changed.
21
+ /// </summary>
22
+ public bool UpdatedValue { get; set; }
23
+
24
+ /// <summary>
25
+ /// Resolved value.
26
+ /// </summary>
27
+ public string Value { get; set; }
28
+ }
29
+}
\ No newline at end of file
src/WixToolset.Core/VariableResolver.cs
+8
-3
@@ -23,6 +23,7 @@ namespace WixToolset.Core
23
/// </summary>
24
internal VariableResolver(IServiceProvider serviceProvider)
25
{
26
+ this.ServiceProvider = serviceProvider;
27
this.Messaging = serviceProvider.GetService<IMessaging>();
28
29
this.locVariables = new Dictionary<string, BindVariable>();
@@ -31,6 +32,8 @@ namespace WixToolset.Core
32
this.Codepage = -1;
33
}
34
35
+ private IServiceProvider ServiceProvider { get; }
36
+
37
private IMessaging Messaging { get; }
38
39
public int Codepage { get; private set; }
@@ -71,7 +74,7 @@ namespace WixToolset.Core
74
}
75
}
76
74
- public VariableResolution ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly)
77
+ public IVariableResolution ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly)
78
{
79
return this.ResolveVariables(sourceLineNumbers, value, localizationOnly, true);
80
}
@@ -90,12 +93,14 @@ namespace WixToolset.Core
93
/// <param name="localizationOnly">true to only resolve localization variables; false otherwise.</param>
94
/// <param name="errorOnUnknown">true if unknown variables should throw errors.</param>
95
/// <returns>The resolved value.</returns>
93
- internal VariableResolution ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly, bool errorOnUnknown)
96
+ internal IVariableResolution ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly, bool errorOnUnknown)
97
{
98
var matches = Common.WixVariableRegex.Matches(value);
99
100
// the value is the default unless its substituted further down
98
- var result = new VariableResolution { IsDefault = true, Value = value };
101
+ var result = this.ServiceProvider.GetService<IVariableResolution>();
102
+ result.IsDefault = true;
103
+ result.Value = value;
104
105
if (0 < matches.Count)
106
{
src/WixToolset.Core/WixToolsetServiceProvider.cs
+13
-1
@@ -40,6 +40,15 @@ namespace WixToolset.Core
40
this.AddService<ILayoutContext>((provider, singletons) => new LayoutContext(provider));
41
this.AddService<IInscribeContext>((provider, singletons) => new InscribeContext(provider));
42
43
+ this.AddService<IBindFileWithPath>((provider, singletons) => new BindFileWithPath());
44
+ this.AddService<IBindPath>((provider, singletons) => new BindPath());
45
+ this.AddService<IBindResult>((provider, singletons) => new BindResult());
46
+ this.AddService<IComponentKeyPath>((provider, singletons) => new ComponentKeyPath());
47
+ this.AddService<IDecompileResult>((provider, singletons) => new DecompileResult());
48
+ this.AddService<IResolveResult>((provider, singletons) => new ResolveResult());
49
+ this.AddService<IResolvedCabinet>((provider, singletons) => new ResolvedCabinet());
50
+ this.AddService<IVariableResolution>((provider, singletons) => new VariableResolution());
51
+
52
this.AddService<IBinder>((provider, singletons) => new Binder(provider));
53
this.AddService<ICompiler>((provider, singletons) => new Compiler(provider));
54
this.AddService<IDecompiler>((provider, singletons) => new Decompiler(provider));
@@ -59,7 +68,10 @@ namespace WixToolset.Core
68
69
public bool TryGetService(Type serviceType, out object service)
70
{
62
- if (serviceType == null) throw new ArgumentNullException(nameof(serviceType));
71
+ if (serviceType == null)
72
+ {
73
+ throw new ArgumentNullException(nameof(serviceType));
74
+ }
75
76
if (!this.Singletons.TryGetValue(serviceType, out service))
77
{