diff options
7 files changed, 50 insertions, 93 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index ffaf1479..bdb089ee 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | |||
| @@ -403,13 +403,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 403 | 403 | ||
| 404 | this.ValidateComponentGuids(output); | 404 | this.ValidateComponentGuids(output); |
| 405 | 405 | ||
| 406 | // We can create instance transforms since Component Guids and Outputs are created. | ||
| 407 | if (output.Type == OutputType.Product) | ||
| 408 | { | ||
| 409 | var command = new CreateInstanceTransformsCommand(section, output, tableDefinitions, this.BackendHelper); | ||
| 410 | command.Execute(); | ||
| 411 | } | ||
| 412 | |||
| 413 | // Stop processing if an error previously occurred. | 406 | // Stop processing if an error previously occurred. |
| 414 | if (this.Messaging.EncounteredError) | 407 | if (this.Messaging.EncounteredError) |
| 415 | { | 408 | { |
| @@ -452,19 +445,25 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 452 | trackedFiles.AddRange(command.TrackedFiles); | 445 | trackedFiles.AddRange(command.TrackedFiles); |
| 453 | } | 446 | } |
| 454 | 447 | ||
| 455 | if (output.Type == OutputType.Patch) | ||
| 456 | { | ||
| 457 | // Copy output data back into the transforms. | ||
| 458 | var command = new UpdateTransformsWithFileFacades(this.Messaging, output, this.SubStorages, tableDefinitions, fileFacades); | ||
| 459 | command.Execute(); | ||
| 460 | } | ||
| 461 | |||
| 462 | // stop processing if an error previously occurred | 448 | // stop processing if an error previously occurred |
| 463 | if (this.Messaging.EncounteredError) | 449 | if (this.Messaging.EncounteredError) |
| 464 | { | 450 | { |
| 465 | return null; | 451 | return null; |
| 466 | } | 452 | } |
| 467 | 453 | ||
| 454 | // We can create instance transforms since Component Guids and Outputs are created. | ||
| 455 | if (output.Type == OutputType.Product) | ||
| 456 | { | ||
| 457 | var command = new CreateInstanceTransformsCommand(section, output, tableDefinitions, this.BackendHelper); | ||
| 458 | command.Execute(); | ||
| 459 | } | ||
| 460 | else if (output.Type == OutputType.Patch) | ||
| 461 | { | ||
| 462 | // Copy output data back into the transforms. | ||
| 463 | var command = new UpdateTransformsWithFileFacades(this.Messaging, output, this.SubStorages, tableDefinitions, fileFacades); | ||
| 464 | command.Execute(); | ||
| 465 | } | ||
| 466 | |||
| 468 | // Generate database file. | 467 | // Generate database file. |
| 469 | this.Messaging.Write(VerboseMessages.GeneratingDatabase()); | 468 | this.Messaging.Write(VerboseMessages.GeneratingDatabase()); |
| 470 | 469 | ||
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateTransformsWithFileFacades.cs b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateTransformsWithFileFacades.cs index af2e8f85..2af45e77 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateTransformsWithFileFacades.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateTransformsWithFileFacades.cs | |||
| @@ -4,8 +4,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 7 | using System.Diagnostics; | ||
| 8 | using System.IO; | ||
| 9 | using System.Linq; | 7 | using System.Linq; |
| 10 | using WixToolset.Core.Bind; | 8 | using WixToolset.Core.Bind; |
| 11 | using WixToolset.Data; | 9 | using WixToolset.Data; |
diff --git a/src/WixToolset.Core/CommandLine/CommandLine.cs b/src/WixToolset.Core/CommandLine/CommandLine.cs index 79f5d5bc..744e05b8 100644 --- a/src/WixToolset.Core/CommandLine/CommandLine.cs +++ b/src/WixToolset.Core/CommandLine/CommandLine.cs | |||
| @@ -54,35 +54,6 @@ namespace WixToolset.Core.CommandLine | |||
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | return command; | 56 | return command; |
| 57 | //switch (commandType) | ||
| 58 | //{ | ||
| 59 | //case CommandTypes.Build: | ||
| 60 | //{ | ||
| 61 | // var sourceFiles = GatherSourceFiles(files, outputFolder); | ||
| 62 | // var variables = this.GatherPreprocessorVariables(defines); | ||
| 63 | // var bindPathList = this.GatherBindPaths(bindPaths); | ||
| 64 | // var filterCultures = CalculateFilterCultures(cultures); | ||
| 65 | // var type = CalculateOutputType(outputType, outputFile); | ||
| 66 | // var platform = CalculatePlatform(platformType); | ||
| 67 | // return new BuildCommand(this.ServiceProvider, sourceFiles, variables, locFiles, libraryFiles, filterCultures, outputFile, type, platform, cabCachePath, bindFiles, bindPathList, includePaths, intermediateFolder, contentsFile, outputsFile, builtOutputsFile); | ||
| 68 | //} | ||
| 69 | |||
| 70 | //case CommandTypes.Compile: | ||
| 71 | //{ | ||
| 72 | // var sourceFiles = GatherSourceFiles(files, outputFolder); | ||
| 73 | // var variables = this.GatherPreprocessorVariables(defines); | ||
| 74 | // var platform = CalculatePlatform(platformType); | ||
| 75 | // return new CompileCommand(this.ServiceProvider, sourceFiles, variables, platform); | ||
| 76 | //} | ||
| 77 | |||
| 78 | //case CommandTypes.Decompile: | ||
| 79 | //{ | ||
| 80 | // var sourceFiles = GatherSourceFiles(files, outputFolder); | ||
| 81 | // return new DecompileCommand(this.ServiceProvider, sourceFiles, outputFile); | ||
| 82 | //} | ||
| 83 | //} | ||
| 84 | |||
| 85 | //return null; | ||
| 86 | } | 57 | } |
| 87 | 58 | ||
| 88 | private ICommandLineCommand Parse(ICommandLineContext context) | 59 | private ICommandLineCommand Parse(ICommandLineContext context) |
| @@ -109,7 +80,7 @@ namespace WixToolset.Core.CommandLine | |||
| 109 | // First argument must be the command or global switch (that creates a command). | 80 | // First argument must be the command or global switch (that creates a command). |
| 110 | if (command == null) | 81 | if (command == null) |
| 111 | { | 82 | { |
| 112 | if (!this.TryParseUnknownCommandArg(arg, parser, out command, extensions)) | 83 | if (!this.TryParseCommand(arg, parser, out command, extensions)) |
| 113 | { | 84 | { |
| 114 | parser.ErrorArgument = arg; | 85 | parser.ErrorArgument = arg; |
| 115 | } | 86 | } |
| @@ -121,7 +92,7 @@ namespace WixToolset.Core.CommandLine | |||
| 121 | parser.ErrorArgument = arg; | 92 | parser.ErrorArgument = arg; |
| 122 | } | 93 | } |
| 123 | } | 94 | } |
| 124 | else if (!TryParseCommandLineArgumentWithExtension(arg, parser, extensions) && command?.TryParseArgument(parser, arg) == false) | 95 | else if (!TryParseCommandLineArgumentWithExtension(arg, parser, extensions) && !command.TryParseArgument(parser, arg)) |
| 125 | { | 96 | { |
| 126 | parser.ErrorArgument = arg; | 97 | parser.ErrorArgument = arg; |
| 127 | } | 98 | } |
| @@ -135,7 +106,7 @@ namespace WixToolset.Core.CommandLine | |||
| 135 | return command ?? new HelpCommand(); | 106 | return command ?? new HelpCommand(); |
| 136 | } | 107 | } |
| 137 | 108 | ||
| 138 | private bool TryParseUnknownCommandArg(string arg, ICommandLineParser parser, out ICommandLineCommand command, IEnumerable<IExtensionCommandLine> extensions) | 109 | private bool TryParseCommand(string arg, ICommandLineParser parser, out ICommandLineCommand command, IEnumerable<IExtensionCommandLine> extensions) |
| 139 | { | 110 | { |
| 140 | command = null; | 111 | command = null; |
| 141 | 112 | ||
| @@ -147,6 +118,7 @@ namespace WixToolset.Core.CommandLine | |||
| 147 | case "?": | 118 | case "?": |
| 148 | case "h": | 119 | case "h": |
| 149 | case "help": | 120 | case "help": |
| 121 | case "-help": | ||
| 150 | command = new HelpCommand(); | 122 | command = new HelpCommand(); |
| 151 | break; | 123 | break; |
| 152 | 124 | ||
| @@ -179,7 +151,7 @@ namespace WixToolset.Core.CommandLine | |||
| 179 | { | 151 | { |
| 180 | foreach (var extension in extensions) | 152 | foreach (var extension in extensions) |
| 181 | { | 153 | { |
| 182 | if (extension.TryParseCommand(parser, out command)) | 154 | if (extension.TryParseCommand(parser, arg, out command)) |
| 183 | { | 155 | { |
| 184 | break; | 156 | break; |
| 185 | } | 157 | } |
diff --git a/src/WixToolset.Core/CommandLine/CommandLineArguments.cs b/src/WixToolset.Core/CommandLine/CommandLineArguments.cs index 3f412611..456e19d7 100644 --- a/src/WixToolset.Core/CommandLine/CommandLineArguments.cs +++ b/src/WixToolset.Core/CommandLine/CommandLineArguments.cs | |||
| @@ -12,6 +12,11 @@ namespace WixToolset.Core.CommandLine | |||
| 12 | 12 | ||
| 13 | internal class CommandLineArguments : ICommandLineArguments | 13 | internal class CommandLineArguments : ICommandLineArguments |
| 14 | { | 14 | { |
| 15 | public CommandLineArguments(IWixToolsetServiceProvider serviceProvider) | ||
| 16 | { | ||
| 17 | this.Messaging = serviceProvider.GetService<IMessaging>(); | ||
| 18 | } | ||
| 19 | |||
| 15 | public string[] OriginalArguments { get; set; } | 20 | public string[] OriginalArguments { get; set; } |
| 16 | 21 | ||
| 17 | public string[] Arguments { get; set; } | 22 | public string[] Arguments { get; set; } |
| @@ -20,12 +25,7 @@ namespace WixToolset.Core.CommandLine | |||
| 20 | 25 | ||
| 21 | public string ErrorArgument { get; set; } | 26 | public string ErrorArgument { get; set; } |
| 22 | 27 | ||
| 23 | private IWixToolsetServiceProvider ServiceProvider { get; } | 28 | private IMessaging Messaging { get; } |
| 24 | |||
| 25 | public CommandLineArguments(IWixToolsetServiceProvider serviceProvider) | ||
| 26 | { | ||
| 27 | this.ServiceProvider = serviceProvider; | ||
| 28 | } | ||
| 29 | 29 | ||
| 30 | public void Populate(string commandLine) | 30 | public void Populate(string commandLine) |
| 31 | { | 31 | { |
| @@ -41,27 +41,25 @@ namespace WixToolset.Core.CommandLine | |||
| 41 | this.ProcessArgumentsAndParseExtensions(this.OriginalArguments); | 41 | this.ProcessArgumentsAndParseExtensions(this.OriginalArguments); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | public ICommandLineParser Parse() | 44 | public ICommandLineParser Parse() => new CommandLineParser(this.Messaging, this.Arguments, this.ErrorArgument); |
| 45 | { | ||
| 46 | var messaging = this.ServiceProvider.GetService<IMessaging>(); | ||
| 47 | |||
| 48 | return new CommandLineParser(messaging, this.Arguments, this.ErrorArgument); | ||
| 49 | } | ||
| 50 | 45 | ||
| 51 | private void FlattenArgumentsWithResponseFilesIntoOriginalArguments(string[] commandLineArguments) | 46 | private void FlattenArgumentsWithResponseFilesIntoOriginalArguments(string[] commandLineArguments) |
| 52 | { | 47 | { |
| 53 | List<string> args = new List<string>(); | 48 | var args = new List<string>(); |
| 54 | 49 | ||
| 55 | foreach (var arg in commandLineArguments) | 50 | foreach (var arg in commandLineArguments) |
| 56 | { | 51 | { |
| 57 | if ('@' == arg[0]) | 52 | if (arg != null) |
| 58 | { | 53 | { |
| 59 | var responseFileArguments = CommandLineArguments.ParseResponseFile(arg.Substring(1)); | 54 | if ('@' == arg[0]) |
| 60 | args.AddRange(responseFileArguments); | 55 | { |
| 61 | } | 56 | var responseFileArguments = CommandLineArguments.ParseResponseFile(arg.Substring(1)); |
| 62 | else | 57 | args.AddRange(responseFileArguments); |
| 63 | { | 58 | } |
| 64 | args.Add(arg); | 59 | else |
| 60 | { | ||
| 61 | args.Add(arg); | ||
| 62 | } | ||
| 65 | } | 63 | } |
| 66 | } | 64 | } |
| 67 | 65 | ||
| @@ -103,7 +101,7 @@ namespace WixToolset.Core.CommandLine | |||
| 103 | { | 101 | { |
| 104 | string arguments; | 102 | string arguments; |
| 105 | 103 | ||
| 106 | using (StreamReader reader = new StreamReader(responseFile)) | 104 | using (var reader = new StreamReader(responseFile)) |
| 107 | { | 105 | { |
| 108 | arguments = reader.ReadToEnd(); | 106 | arguments = reader.ReadToEnd(); |
| 109 | } | 107 | } |
| @@ -131,7 +129,7 @@ namespace WixToolset.Core.CommandLine | |||
| 131 | // The current argument string being built; when completed it will be added to the list. | 129 | // The current argument string being built; when completed it will be added to the list. |
| 132 | var arg = new StringBuilder(); | 130 | var arg = new StringBuilder(); |
| 133 | 131 | ||
| 134 | for (int i = 0; i <= arguments.Length; i++) | 132 | for (var i = 0; i <= arguments.Length; i++) |
| 135 | { | 133 | { |
| 136 | if (i == arguments.Length || (Char.IsWhiteSpace(arguments[i]) && !insideQuote)) | 134 | if (i == arguments.Length || (Char.IsWhiteSpace(arguments[i]) && !insideQuote)) |
| 137 | { | 135 | { |
| @@ -182,10 +180,10 @@ namespace WixToolset.Core.CommandLine | |||
| 182 | var id = Environment.GetEnvironmentVariables(); | 180 | var id = Environment.GetEnvironmentVariables(); |
| 183 | 181 | ||
| 184 | var regex = new Regex("(?<=\\%)(?:[\\w\\.]+)(?=\\%)"); | 182 | var regex = new Regex("(?<=\\%)(?:[\\w\\.]+)(?=\\%)"); |
| 185 | MatchCollection matches = regex.Matches(arguments); | 183 | var matches = regex.Matches(arguments); |
| 186 | 184 | ||
| 187 | string value = String.Empty; | 185 | var value = String.Empty; |
| 188 | for (int i = 0; i <= (matches.Count - 1); i++) | 186 | for (var i = 0; i <= (matches.Count - 1); i++) |
| 189 | { | 187 | { |
| 190 | try | 188 | try |
| 191 | { | 189 | { |
| @@ -204,9 +202,6 @@ namespace WixToolset.Core.CommandLine | |||
| 204 | return arguments; | 202 | return arguments; |
| 205 | } | 203 | } |
| 206 | 204 | ||
| 207 | private static bool IsSwitchAt(string[] args, int index) | 205 | private static bool IsSwitchAt(string[] args, int index) => args.Length > index && !String.IsNullOrEmpty(args[index]) && ('/' == args[index][0] || '-' == args[index][0]); |
| 208 | { | ||
| 209 | return args.Length > index && !String.IsNullOrEmpty(args[index]) && ('/' == args[index][0] || '-' == args[index][0]); | ||
| 210 | } | ||
| 211 | } | 206 | } |
| 212 | } | 207 | } |
diff --git a/src/WixToolset.Core/CommandLine/VersionCommand.cs b/src/WixToolset.Core/CommandLine/VersionCommand.cs index 1baee72d..50e90a93 100644 --- a/src/WixToolset.Core/CommandLine/VersionCommand.cs +++ b/src/WixToolset.Core/CommandLine/VersionCommand.cs | |||
| @@ -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 | 2 | ||
| 3 | namespace WixToolset.Core.CommandLine | 3 | namespace WixToolset.Core.CommandLine |
| 4 | { | 4 | { |
| @@ -20,9 +20,6 @@ namespace WixToolset.Core.CommandLine | |||
| 20 | return 0; | 20 | return 0; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | public bool TryParseArgument(ICommandLineParser parseHelper, string argument) | 23 | public bool TryParseArgument(ICommandLineParser parseHelper, string argument) => true; // eat any arguments |
| 24 | { | ||
| 25 | return true; // eat any arguments | ||
| 26 | } | ||
| 27 | } | 24 | } |
| 28 | } | 25 | } |
diff --git a/src/WixToolset.Core/WixToolsetServiceProvider.cs b/src/WixToolset.Core/WixToolsetServiceProvider.cs index 2cd097a4..1d475d00 100644 --- a/src/WixToolset.Core/WixToolsetServiceProvider.cs +++ b/src/WixToolset.Core/WixToolsetServiceProvider.cs | |||
| @@ -96,8 +96,7 @@ namespace WixToolset.Core | |||
| 96 | return service != null; | 96 | return service != null; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | public bool TryGetService<T>(out T service) | 99 | public bool TryGetService<T>(out T service) where T : class |
| 100 | where T : class | ||
| 101 | { | 100 | { |
| 102 | var success = this.TryGetService(typeof(T), out var untypedService); | 101 | var success = this.TryGetService(typeof(T), out var untypedService); |
| 103 | service = (T)untypedService; | 102 | service = (T)untypedService; |
| @@ -109,8 +108,7 @@ namespace WixToolset.Core | |||
| 109 | return this.TryGetService(serviceType, out var service) ? service : throw new ArgumentException($"Unknown service type: {serviceType.Name}", nameof(serviceType)); | 108 | return this.TryGetService(serviceType, out var service) ? service : throw new ArgumentException($"Unknown service type: {serviceType.Name}", nameof(serviceType)); |
| 110 | } | 109 | } |
| 111 | 110 | ||
| 112 | public T GetService<T>() | 111 | public T GetService<T>() where T : class |
| 113 | where T : class | ||
| 114 | { | 112 | { |
| 115 | return (T)this.GetService(typeof(T)); | 113 | return (T)this.GetService(typeof(T)); |
| 116 | } | 114 | } |
| @@ -120,14 +118,12 @@ namespace WixToolset.Core | |||
| 120 | this.CreationFunctions[serviceType] = creationFunction; | 118 | this.CreationFunctions[serviceType] = creationFunction; |
| 121 | } | 119 | } |
| 122 | 120 | ||
| 123 | public void AddService<T>(Func<IWixToolsetCoreServiceProvider, Dictionary<Type, object>, T> creationFunction) | 121 | public void AddService<T>(Func<IWixToolsetCoreServiceProvider, Dictionary<Type, object>, T> creationFunction) where T : class |
| 124 | where T : class | ||
| 125 | { | 122 | { |
| 126 | this.AddService(typeof(T), creationFunction); | 123 | this.AddService(typeof(T), creationFunction); |
| 127 | } | 124 | } |
| 128 | 125 | ||
| 129 | private static T AddSingleton<T>(Dictionary<Type, object> singletons, T service) | 126 | private static T AddSingleton<T>(Dictionary<Type, object> singletons, T service) where T : class |
| 130 | where T : class | ||
| 131 | { | 127 | { |
| 132 | singletons.Add(typeof(T), service); | 128 | singletons.Add(typeof(T), service); |
| 133 | return service; | 129 | return service; |
diff --git a/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs b/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs index eddcf6e4..49f68de5 100644 --- a/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs +++ b/src/test/Example.Extension/ExamplePreprocessorExtensionAndCommandLine.cs | |||
| @@ -34,7 +34,7 @@ namespace Example.Extension | |||
| 34 | return false; | 34 | return false; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | public bool TryParseCommand(ICommandLineParser parser, out ICommandLineCommand command) | 37 | public bool TryParseCommand(ICommandLineParser parser, string argument, out ICommandLineCommand command) |
| 38 | { | 38 | { |
| 39 | command = null; | 39 | command = null; |
| 40 | return false; | 40 | return false; |
| @@ -54,4 +54,4 @@ namespace Example.Extension | |||
| 54 | return null; | 54 | return null; |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
| 57 | } \ No newline at end of file | 57 | } |
