aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2020-05-08 20:25:11 -0400
committerBob Arnson <bob@firegiant.com>2020-05-08 20:28:30 -0400
commitd47527d4af6066969ea9abee83ef9b172e4e1d98 (patch)
tree023dd8e9c6add0fec8f2440086f29ce6141c698f /src
parentd2da673f3b2676663748efe359389e0553609dcf (diff)
downloadwix-d47527d4af6066969ea9abee83ef9b172e4e1d98.tar.gz
wix-d47527d4af6066969ea9abee83ef9b172e4e1d98.tar.bz2
wix-d47527d4af6066969ea9abee83ef9b172e4e1d98.zip
Default output file if there's a single input file.
Diffstat (limited to 'src')
-rw-r--r--src/WixToolset.Core/CommandLine/BuildCommand.cs75
1 files changed, 71 insertions, 4 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs
index a59637fe..dbdad0a9 100644
--- a/src/WixToolset.Core/CommandLine/BuildCommand.cs
+++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs
@@ -74,8 +74,6 @@ namespace WixToolset.Core.CommandLine
74 74
75 this.Platform = this.commandLine.Platform; 75 this.Platform = this.commandLine.Platform;
76 76
77 this.OutputFile = this.commandLine.OutputFile;
78
79 this.ContentsFile = this.commandLine.ContentsFile; 77 this.ContentsFile = this.commandLine.ContentsFile;
80 78
81 this.OutputsFile = this.commandLine.OutputsFile; 79 this.OutputsFile = this.commandLine.OutputsFile;
@@ -92,6 +90,21 @@ namespace WixToolset.Core.CommandLine
92 90
93 this.EvaluateSourceFiles(sourceFiles, creator, out var codeFiles, out var wixipl); 91 this.EvaluateSourceFiles(sourceFiles, creator, out var codeFiles, out var wixipl);
94 92
93 this.OutputFile = this.commandLine.OutputFile;
94
95 if (String.IsNullOrEmpty(this.OutputFile))
96 {
97 if (codeFiles.Count == 1)
98 {
99 // If output type is unknown, the extension will be replaced with the right default based on output type.
100 this.OutputFile = Path.ChangeExtension(codeFiles[0].OutputPath, DefaultExtensionForOutputType(this.OutputType));
101 }
102 else
103 {
104 this.Messaging.Write(ErrorMessages.MustSpecifyOutputWithMoreThanOneInput());
105 }
106 }
107
95 if (this.Messaging.EncounteredError) 108 if (this.Messaging.EncounteredError)
96 { 109 {
97 return this.Messaging.LastErrorNumber; 110 return this.Messaging.LastErrorNumber;
@@ -114,7 +127,7 @@ namespace WixToolset.Core.CommandLine
114 127
115 if (!this.Messaging.EncounteredError) 128 if (!this.Messaging.EncounteredError)
116 { 129 {
117 wixlib.Save(this.commandLine.OutputFile); 130 wixlib.Save(this.OutputFile);
118 } 131 }
119 } 132 }
120 } 133 }
@@ -129,9 +142,16 @@ namespace WixToolset.Core.CommandLine
129 142
130 if (!this.Messaging.EncounteredError) 143 if (!this.Messaging.EncounteredError)
131 { 144 {
145 var outputExtension = Path.GetExtension(this.OutputFile);
146 if (String.IsNullOrEmpty(outputExtension) || ".wix" == outputExtension)
147 {
148 var entrySectionType = wixipl.Sections.Single().Type;
149 this.OutputFile = Path.ChangeExtension(this.OutputFile, DefaultExtensionForSectionType(entrySectionType));
150 }
151
132 if (this.OutputType == OutputType.IntermediatePostLink) 152 if (this.OutputType == OutputType.IntermediatePostLink)
133 { 153 {
134 wixipl.Save(this.commandLine.OutputFile); 154 wixipl.Save(this.OutputFile);
135 } 155 }
136 else 156 else
137 { 157 {
@@ -416,6 +436,53 @@ namespace WixToolset.Core.CommandLine
416 return result?.Document; 436 return result?.Document;
417 } 437 }
418 438
439 private static string DefaultExtensionForSectionType(SectionType sectionType)
440 {
441 switch (sectionType)
442 {
443 case SectionType.Bundle:
444 return ".exe";
445 case SectionType.Module:
446 return ".msm";
447 case SectionType.Product:
448 return ".msi";
449 case SectionType.PatchCreation:
450 return ".pcp";
451 case SectionType.Patch:
452 return ".msp";
453 case SectionType.Fragment:
454 case SectionType.Unknown:
455 default:
456 return ".wix";
457 }
458 }
459
460 private static string DefaultExtensionForOutputType(OutputType outputType)
461 {
462 switch (outputType)
463 {
464 case OutputType.Bundle:
465 return ".exe";
466 case OutputType.Library:
467 return ".wixlib";
468 case OutputType.Module:
469 return ".msm";
470 case OutputType.Patch:
471 return ".msp";
472 case OutputType.PatchCreation:
473 return ".pcp";
474 case OutputType.Product:
475 return ".msi";
476 case OutputType.Transform:
477 return ".mst";
478 case OutputType.IntermediatePostLink:
479 return ".wixipl";
480 case OutputType.Unknown:
481 default:
482 return ".wix";
483 }
484 }
485
419 private class CommandLine 486 private class CommandLine
420 { 487 {
421 private static readonly char[] BindPathSplit = { '=' }; 488 private static readonly char[] BindPathSplit = { '=' };