diff options
Diffstat (limited to 'src/WixToolset.Core/CommandLine/CommandLine.cs')
| -rw-r--r-- | src/WixToolset.Core/CommandLine/CommandLine.cs | 115 |
1 files changed, 95 insertions, 20 deletions
diff --git a/src/WixToolset.Core/CommandLine/CommandLine.cs b/src/WixToolset.Core/CommandLine/CommandLine.cs index 440ae9ef..cac54091 100644 --- a/src/WixToolset.Core/CommandLine/CommandLine.cs +++ b/src/WixToolset.Core/CommandLine/CommandLine.cs | |||
| @@ -57,14 +57,20 @@ namespace WixToolset.Core | |||
| 57 | var showVersion = false; | 57 | var showVersion = false; |
| 58 | var outputFolder = String.Empty; | 58 | var outputFolder = String.Empty; |
| 59 | var outputFile = String.Empty; | 59 | var outputFile = String.Empty; |
| 60 | var sourceFile = String.Empty; | 60 | var outputType = String.Empty; |
| 61 | var verbose = false; | 61 | var verbose = false; |
| 62 | var files = new List<string>(); | 62 | var files = new List<string>(); |
| 63 | var defines = new List<string>(); | 63 | var defines = new List<string>(); |
| 64 | var includePaths = new List<string>(); | 64 | var includePaths = new List<string>(); |
| 65 | var locFiles = new List<string>(); | 65 | var locFiles = new List<string>(); |
| 66 | var libraryFiles = new List<string>(); | ||
| 66 | var suppressedWarnings = new List<int>(); | 67 | var suppressedWarnings = new List<int>(); |
| 67 | 68 | ||
| 69 | var bindFiles = false; | ||
| 70 | var bindPaths = new List<string>(); | ||
| 71 | |||
| 72 | var intermediateFolder = String.Empty; | ||
| 73 | |||
| 68 | var cultures = new List<string>(); | 74 | var cultures = new List<string>(); |
| 69 | var contentsFile = String.Empty; | 75 | var contentsFile = String.Empty; |
| 70 | var outputsFile = String.Empty; | 76 | var outputsFile = String.Empty; |
| @@ -84,6 +90,14 @@ namespace WixToolset.Core | |||
| 84 | cmdline.ShowHelp = true; | 90 | cmdline.ShowHelp = true; |
| 85 | return true; | 91 | return true; |
| 86 | 92 | ||
| 93 | case "bindfiles": | ||
| 94 | bindFiles = true; | ||
| 95 | return true; | ||
| 96 | |||
| 97 | case "bindpath": | ||
| 98 | cmdline.GetNextArgumentOrError(bindPaths); | ||
| 99 | return true; | ||
| 100 | |||
| 87 | case "cultures": | 101 | case "cultures": |
| 88 | cmdline.GetNextArgumentOrError(cultures); | 102 | cmdline.GetNextArgumentOrError(cultures); |
| 89 | return true; | 103 | return true; |
| @@ -110,15 +124,27 @@ namespace WixToolset.Core | |||
| 110 | cmdline.GetNextArgumentOrError(includePaths); | 124 | cmdline.GetNextArgumentOrError(includePaths); |
| 111 | return true; | 125 | return true; |
| 112 | 126 | ||
| 127 | case "intermediatefolder": | ||
| 128 | cmdline.GetNextArgumentOrError(ref intermediateFolder); | ||
| 129 | return true; | ||
| 130 | |||
| 113 | case "loc": | 131 | case "loc": |
| 114 | cmdline.GetNextArgumentAsFilePathOrError(locFiles, "localization files"); | 132 | cmdline.GetNextArgumentAsFilePathOrError(locFiles, "localization files"); |
| 115 | return true; | 133 | return true; |
| 116 | 134 | ||
| 135 | case "lib": | ||
| 136 | cmdline.GetNextArgumentAsFilePathOrError(libraryFiles, "library files"); | ||
| 137 | return true; | ||
| 138 | |||
| 117 | case "o": | 139 | case "o": |
| 118 | case "out": | 140 | case "out": |
| 119 | cmdline.GetNextArgumentOrError(ref outputFile); | 141 | cmdline.GetNextArgumentOrError(ref outputFile); |
| 120 | return true; | 142 | return true; |
| 121 | 143 | ||
| 144 | case "outputtype": | ||
| 145 | cmdline.GetNextArgumentOrError(ref outputType); | ||
| 146 | return true; | ||
| 147 | |||
| 122 | case "nologo": | 148 | case "nologo": |
| 123 | showLogo = false; | 149 | showLogo = false; |
| 124 | return true; | 150 | return true; |
| @@ -143,6 +169,8 @@ namespace WixToolset.Core | |||
| 143 | } | 169 | } |
| 144 | }); | 170 | }); |
| 145 | 171 | ||
| 172 | Messaging.Instance.ShowVerboseMessages = verbose; | ||
| 173 | |||
| 146 | if (showVersion) | 174 | if (showVersion) |
| 147 | { | 175 | { |
| 148 | return new VersionCommand(); | 176 | return new VersionCommand(); |
| @@ -164,8 +192,10 @@ namespace WixToolset.Core | |||
| 164 | { | 192 | { |
| 165 | var sourceFiles = GatherSourceFiles(files, outputFolder); | 193 | var sourceFiles = GatherSourceFiles(files, outputFolder); |
| 166 | var variables = GatherPreprocessorVariables(defines); | 194 | var variables = GatherPreprocessorVariables(defines); |
| 195 | var bindPathList = GatherBindPaths(bindPaths); | ||
| 167 | var extensions = cli.ExtensionManager; | 196 | var extensions = cli.ExtensionManager; |
| 168 | return new BuildCommand(sourceFiles, variables, locFiles, outputFile, cultures, contentsFile, outputsFile, builtOutputsFile, wixProjectFile); | 197 | var type = CalculateOutputType(outputType, outputFile); |
| 198 | return new BuildCommand(sourceFiles, variables, locFiles, libraryFiles, outputFile, type, cultures, bindFiles, bindPathList, intermediateFolder, contentsFile, outputsFile, builtOutputsFile, wixProjectFile); | ||
| 169 | } | 199 | } |
| 170 | 200 | ||
| 171 | case Commands.Compile: | 201 | case Commands.Compile: |
| @@ -179,6 +209,46 @@ namespace WixToolset.Core | |||
| 179 | return null; | 209 | return null; |
| 180 | } | 210 | } |
| 181 | 211 | ||
| 212 | private static OutputType CalculateOutputType(string outputType, string outputFile) | ||
| 213 | { | ||
| 214 | if (String.IsNullOrEmpty(outputType)) | ||
| 215 | { | ||
| 216 | outputType = Path.GetExtension(outputFile); | ||
| 217 | } | ||
| 218 | |||
| 219 | switch (outputType.ToLowerInvariant()) | ||
| 220 | { | ||
| 221 | case "bundle": | ||
| 222 | case ".exe": | ||
| 223 | return OutputType.Bundle; | ||
| 224 | |||
| 225 | case "library": | ||
| 226 | case ".wixlib": | ||
| 227 | return OutputType.Library; | ||
| 228 | |||
| 229 | case "module": | ||
| 230 | case ".msm": | ||
| 231 | return OutputType.Module; | ||
| 232 | |||
| 233 | case "patch": | ||
| 234 | case ".msp": | ||
| 235 | return OutputType.Patch; | ||
| 236 | |||
| 237 | case ".pcp": | ||
| 238 | return OutputType.PatchCreation; | ||
| 239 | |||
| 240 | case "product": | ||
| 241 | case ".msi": | ||
| 242 | return OutputType.Product; | ||
| 243 | |||
| 244 | case "transform": | ||
| 245 | case ".mst": | ||
| 246 | return OutputType.Transform; | ||
| 247 | } | ||
| 248 | |||
| 249 | return OutputType.Unknown; | ||
| 250 | } | ||
| 251 | |||
| 182 | private static CommandLine Parse(string commandLineString, Func<CommandLine, string, bool> parseArgument) | 252 | private static CommandLine Parse(string commandLineString, Func<CommandLine, string, bool> parseArgument) |
| 183 | { | 253 | { |
| 184 | var arguments = CommandLine.ParseArgumentsToArray(commandLineString).ToArray(); | 254 | var arguments = CommandLine.ParseArgumentsToArray(commandLineString).ToArray(); |
| @@ -239,6 +309,26 @@ namespace WixToolset.Core | |||
| 239 | return variables; | 309 | return variables; |
| 240 | } | 310 | } |
| 241 | 311 | ||
| 312 | private static IEnumerable<BindPath> GatherBindPaths(IEnumerable<string> bindPaths) | ||
| 313 | { | ||
| 314 | var result = new List<BindPath>(); | ||
| 315 | |||
| 316 | foreach (var bindPath in bindPaths) | ||
| 317 | { | ||
| 318 | BindPath bp = BindPath.Parse(bindPath); | ||
| 319 | |||
| 320 | if (Directory.Exists(bp.Path)) | ||
| 321 | { | ||
| 322 | result.Add(bp); | ||
| 323 | } | ||
| 324 | else if (File.Exists(bp.Path)) | ||
| 325 | { | ||
| 326 | Messaging.Instance.OnMessage(WixErrors.ExpectedDirectoryGotFile("-bindpath", bp.Path)); | ||
| 327 | } | ||
| 328 | } | ||
| 329 | |||
| 330 | return result; | ||
| 331 | } | ||
| 242 | 332 | ||
| 243 | /// <summary> | 333 | /// <summary> |
| 244 | /// Get a set of files that possibly have a search pattern in the path (such as '*'). | 334 | /// Get a set of files that possibly have a search pattern in the path (such as '*'). |
| @@ -361,7 +451,7 @@ namespace WixToolset.Core | |||
| 361 | 451 | ||
| 362 | private static bool TryDequeue(Queue<string> q, out string arg) | 452 | private static bool TryDequeue(Queue<string> q, out string arg) |
| 363 | { | 453 | { |
| 364 | if (q.Count> 0) | 454 | if (q.Count > 0) |
| 365 | { | 455 | { |
| 366 | arg = q.Dequeue(); | 456 | arg = q.Dequeue(); |
| 367 | return true; | 457 | return true; |
| @@ -469,11 +559,6 @@ namespace WixToolset.Core | |||
| 469 | return false; | 559 | return false; |
| 470 | } | 560 | } |
| 471 | 561 | ||
| 472 | /// <summary> | ||
| 473 | /// Parses a response file. | ||
| 474 | /// </summary> | ||
| 475 | /// <param name="responseFile">The file to parse.</param> | ||
| 476 | /// <returns>The array of arguments.</returns> | ||
| 477 | private static List<string> ParseResponseFile(string responseFile) | 562 | private static List<string> ParseResponseFile(string responseFile) |
| 478 | { | 563 | { |
| 479 | string arguments; | 564 | string arguments; |
| @@ -486,11 +571,6 @@ namespace WixToolset.Core | |||
| 486 | return CommandLine.ParseArgumentsToArray(arguments); | 571 | return CommandLine.ParseArgumentsToArray(arguments); |
| 487 | } | 572 | } |
| 488 | 573 | ||
| 489 | /// <summary> | ||
| 490 | /// Parses an argument string into an argument array based on whitespace and quoting. | ||
| 491 | /// </summary> | ||
| 492 | /// <param name="arguments">Argument string.</param> | ||
| 493 | /// <returns>Argument array.</returns> | ||
| 494 | private static List<string> ParseArgumentsToArray(string arguments) | 574 | private static List<string> ParseArgumentsToArray(string arguments) |
| 495 | { | 575 | { |
| 496 | // Scan and parse the arguments string, dividing up the arguments based on whitespace. | 576 | // Scan and parse the arguments string, dividing up the arguments based on whitespace. |
| @@ -526,7 +606,7 @@ namespace WixToolset.Core | |||
| 526 | // Add the argument to the list if it's not empty. | 606 | // Add the argument to the list if it's not empty. |
| 527 | if (arg.Length > 0) | 607 | if (arg.Length > 0) |
| 528 | { | 608 | { |
| 529 | argsList.Add(CommandLine.ExpandEnvVars(arg.ToString())); | 609 | argsList.Add(CommandLine.ExpandEnvironmentVariables(arg.ToString())); |
| 530 | arg.Length = 0; | 610 | arg.Length = 0; |
| 531 | } | 611 | } |
| 532 | } | 612 | } |
| @@ -557,12 +637,7 @@ namespace WixToolset.Core | |||
| 557 | return argsList; | 637 | return argsList; |
| 558 | } | 638 | } |
| 559 | 639 | ||
| 560 | /// <summary> | 640 | private static string ExpandEnvironmentVariables(string arguments) |
| 561 | /// Expand enxironment variables contained in the passed string | ||
| 562 | /// </summary> | ||
| 563 | /// <param name="arguments"></param> | ||
| 564 | /// <returns></returns> | ||
| 565 | private static string ExpandEnvVars(string arguments) | ||
| 566 | { | 641 | { |
| 567 | var id = Environment.GetEnvironmentVariables(); | 642 | var id = Environment.GetEnvironmentVariables(); |
| 568 | 643 | ||
