aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2023-09-05 06:27:10 -0700
committerRob Mensching <rob@firegiant.com>2023-09-05 13:54:26 -0700
commit5fa73084c66505c8274d64cc4bf2b72e416a01a6 (patch)
tree4ad29958115edffb26f12b58797e48d4f618ca1e
parent70096fc3dbcc32edf311d3c22d713d4b8fbf7baf (diff)
downloadwix-5fa73084c66505c8274d64cc4bf2b72e416a01a6.tar.gz
wix-5fa73084c66505c8274d64cc4bf2b72e416a01a6.tar.bz2
wix-5fa73084c66505c8274d64cc4bf2b72e416a01a6.zip
Correctly process build -outputType switch
Also add a few additional output types to built-in backends. Fixes 7708
-rw-r--r--src/test/burn/TestData/DependencyTests/PatchA/PatchA.wixproj2
-rw-r--r--src/test/burn/TestData/DependencyTests/PatchB/PatchB.wixproj2
-rw-r--r--src/test/burn/TestData/PatchTests/PatchA2/PatchA2.wixproj4
-rw-r--r--src/test/burn/TestData/SlipstreamTests/PatchA/PatchA.wixproj4
-rw-r--r--src/test/burn/TestData/SlipstreamTests/PatchAB/PatchAB.wixproj4
-rw-r--r--src/test/burn/TestData/SlipstreamTests/PatchAB2/PatchAB2.wixproj4
-rw-r--r--src/wix/WixToolset.Core.Burn/BurnBackendFactory.cs1
-rw-r--r--src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendFactory.cs4
-rw-r--r--src/wix/WixToolset.Core/BindContext.cs2
-rw-r--r--src/wix/WixToolset.Core/Binder.cs15
-rw-r--r--src/wix/WixToolset.Core/CommandLine/BuildCommand.cs5
-rw-r--r--src/wix/WixToolset.Core/CoreErrors.cs6
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs33
13 files changed, 73 insertions, 13 deletions
diff --git a/src/test/burn/TestData/DependencyTests/PatchA/PatchA.wixproj b/src/test/burn/TestData/DependencyTests/PatchA/PatchA.wixproj
index 4809934d..bf20b708 100644
--- a/src/test/burn/TestData/DependencyTests/PatchA/PatchA.wixproj
+++ b/src/test/burn/TestData/DependencyTests/PatchA/PatchA.wixproj
@@ -1,7 +1,7 @@
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<Project Sdk="WixToolset.Sdk"> 2<Project Sdk="WixToolset.Sdk">
3 <PropertyGroup> 3 <PropertyGroup>
4 <OutputType>PatchCreation</OutputType> 4 <OutputType>Patch</OutputType>
5 <TargetExt>.msp</TargetExt> 5 <TargetExt>.msp</TargetExt>
6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings> 6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings>
7 </PropertyGroup> 7 </PropertyGroup>
diff --git a/src/test/burn/TestData/DependencyTests/PatchB/PatchB.wixproj b/src/test/burn/TestData/DependencyTests/PatchB/PatchB.wixproj
index c099f008..5fbdd549 100644
--- a/src/test/burn/TestData/DependencyTests/PatchB/PatchB.wixproj
+++ b/src/test/burn/TestData/DependencyTests/PatchB/PatchB.wixproj
@@ -1,7 +1,7 @@
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<Project Sdk="WixToolset.Sdk"> 2<Project Sdk="WixToolset.Sdk">
3 <PropertyGroup> 3 <PropertyGroup>
4 <OutputType>PatchCreation</OutputType> 4 <OutputType>Patch</OutputType>
5 <TargetExt>.msp</TargetExt> 5 <TargetExt>.msp</TargetExt>
6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings> 6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings>
7 </PropertyGroup> 7 </PropertyGroup>
diff --git a/src/test/burn/TestData/PatchTests/PatchA2/PatchA2.wixproj b/src/test/burn/TestData/PatchTests/PatchA2/PatchA2.wixproj
index da9acb5e..3deb2263 100644
--- a/src/test/burn/TestData/PatchTests/PatchA2/PatchA2.wixproj
+++ b/src/test/burn/TestData/PatchTests/PatchA2/PatchA2.wixproj
@@ -1,7 +1,7 @@
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<Project Sdk="WixToolset.Sdk"> 2<Project Sdk="WixToolset.Sdk">
3 <PropertyGroup> 3 <PropertyGroup>
4 <OutputType>PatchCreation</OutputType> 4 <OutputType>Patch</OutputType>
5 <TargetExt>.msp</TargetExt> 5 <TargetExt>.msp</TargetExt>
6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings> 6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings>
7 </PropertyGroup> 7 </PropertyGroup>
@@ -9,4 +9,4 @@
9 <ProjectReference Include="..\PackageAv1\PackageAv1.wixproj" /> 9 <ProjectReference Include="..\PackageAv1\PackageAv1.wixproj" />
10 <ProjectReference Include="..\PackageAv1_0_1\PackageAv1_0_1.wixproj" /> 10 <ProjectReference Include="..\PackageAv1_0_1\PackageAv1_0_1.wixproj" />
11 </ItemGroup> 11 </ItemGroup>
12</Project> \ No newline at end of file 12</Project>
diff --git a/src/test/burn/TestData/SlipstreamTests/PatchA/PatchA.wixproj b/src/test/burn/TestData/SlipstreamTests/PatchA/PatchA.wixproj
index da9acb5e..3deb2263 100644
--- a/src/test/burn/TestData/SlipstreamTests/PatchA/PatchA.wixproj
+++ b/src/test/burn/TestData/SlipstreamTests/PatchA/PatchA.wixproj
@@ -1,7 +1,7 @@
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<Project Sdk="WixToolset.Sdk"> 2<Project Sdk="WixToolset.Sdk">
3 <PropertyGroup> 3 <PropertyGroup>
4 <OutputType>PatchCreation</OutputType> 4 <OutputType>Patch</OutputType>
5 <TargetExt>.msp</TargetExt> 5 <TargetExt>.msp</TargetExt>
6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings> 6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings>
7 </PropertyGroup> 7 </PropertyGroup>
@@ -9,4 +9,4 @@
9 <ProjectReference Include="..\PackageAv1\PackageAv1.wixproj" /> 9 <ProjectReference Include="..\PackageAv1\PackageAv1.wixproj" />
10 <ProjectReference Include="..\PackageAv1_0_1\PackageAv1_0_1.wixproj" /> 10 <ProjectReference Include="..\PackageAv1_0_1\PackageAv1_0_1.wixproj" />
11 </ItemGroup> 11 </ItemGroup>
12</Project> \ No newline at end of file 12</Project>
diff --git a/src/test/burn/TestData/SlipstreamTests/PatchAB/PatchAB.wixproj b/src/test/burn/TestData/SlipstreamTests/PatchAB/PatchAB.wixproj
index 81fa9e12..5f9ee5f6 100644
--- a/src/test/burn/TestData/SlipstreamTests/PatchAB/PatchAB.wixproj
+++ b/src/test/burn/TestData/SlipstreamTests/PatchAB/PatchAB.wixproj
@@ -1,7 +1,7 @@
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<Project Sdk="WixToolset.Sdk"> 2<Project Sdk="WixToolset.Sdk">
3 <PropertyGroup> 3 <PropertyGroup>
4 <OutputType>PatchCreation</OutputType> 4 <OutputType>Patch</OutputType>
5 <TargetExt>.msp</TargetExt> 5 <TargetExt>.msp</TargetExt>
6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings> 6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings>
7 </PropertyGroup> 7 </PropertyGroup>
@@ -11,4 +11,4 @@
11 <ProjectReference Include="..\PackageBv1\PackageBv1.wixproj" /> 11 <ProjectReference Include="..\PackageBv1\PackageBv1.wixproj" />
12 <ProjectReference Include="..\PackageBv1_0_1\PackageBv1_0_1.wixproj" /> 12 <ProjectReference Include="..\PackageBv1_0_1\PackageBv1_0_1.wixproj" />
13 </ItemGroup> 13 </ItemGroup>
14</Project> \ No newline at end of file 14</Project>
diff --git a/src/test/burn/TestData/SlipstreamTests/PatchAB2/PatchAB2.wixproj b/src/test/burn/TestData/SlipstreamTests/PatchAB2/PatchAB2.wixproj
index 81fa9e12..5f9ee5f6 100644
--- a/src/test/burn/TestData/SlipstreamTests/PatchAB2/PatchAB2.wixproj
+++ b/src/test/burn/TestData/SlipstreamTests/PatchAB2/PatchAB2.wixproj
@@ -1,7 +1,7 @@
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<Project Sdk="WixToolset.Sdk"> 2<Project Sdk="WixToolset.Sdk">
3 <PropertyGroup> 3 <PropertyGroup>
4 <OutputType>PatchCreation</OutputType> 4 <OutputType>Patch</OutputType>
5 <TargetExt>.msp</TargetExt> 5 <TargetExt>.msp</TargetExt>
6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings> 6 <SuppressSpecificWarnings>1079</SuppressSpecificWarnings>
7 </PropertyGroup> 7 </PropertyGroup>
@@ -11,4 +11,4 @@
11 <ProjectReference Include="..\PackageBv1\PackageBv1.wixproj" /> 11 <ProjectReference Include="..\PackageBv1\PackageBv1.wixproj" />
12 <ProjectReference Include="..\PackageBv1_0_1\PackageBv1_0_1.wixproj" /> 12 <ProjectReference Include="..\PackageBv1_0_1\PackageBv1_0_1.wixproj" />
13 </ItemGroup> 13 </ItemGroup>
14</Project> \ No newline at end of file 14</Project>
diff --git a/src/wix/WixToolset.Core.Burn/BurnBackendFactory.cs b/src/wix/WixToolset.Core.Burn/BurnBackendFactory.cs
index 03013a08..63f52200 100644
--- a/src/wix/WixToolset.Core.Burn/BurnBackendFactory.cs
+++ b/src/wix/WixToolset.Core.Burn/BurnBackendFactory.cs
@@ -18,6 +18,7 @@ namespace WixToolset.Core.Burn
18 switch (outputType.ToLowerInvariant()) 18 switch (outputType.ToLowerInvariant())
19 { 19 {
20 case "bundle": 20 case "bundle":
21 case "burn":
21 case ".exe": 22 case ".exe":
22 backend = new BundleBackend(); 23 backend = new BundleBackend();
23 return true; 24 return true;
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendFactory.cs b/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendFactory.cs
index d14743e9..42e1a45d 100644
--- a/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendFactory.cs
+++ b/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendFactory.cs
@@ -18,6 +18,7 @@ namespace WixToolset.Core.WindowsInstaller
18 switch (outputType?.ToLowerInvariant()) 18 switch (outputType?.ToLowerInvariant())
19 { 19 {
20 case "module": 20 case "module":
21 case "msm":
21 case ".msm": 22 case ".msm":
22 backend = new MsmBackend(); 23 backend = new MsmBackend();
23 return true; 24 return true;
@@ -25,11 +26,14 @@ namespace WixToolset.Core.WindowsInstaller
25 case "msipackage": 26 case "msipackage":
26 case "package": 27 case "package":
27 case "product": 28 case "product":
29 case "msi":
28 case ".msi": 30 case ".msi":
29 backend = new MsiBackend(); 31 backend = new MsiBackend();
30 return true; 32 return true;
31 33
34 case "msppackage":
32 case "patch": 35 case "patch":
36 case "msp":
33 case ".msp": 37 case ".msp":
34 backend = new MspBackend(); 38 backend = new MspBackend();
35 return true; 39 return true;
diff --git a/src/wix/WixToolset.Core/BindContext.cs b/src/wix/WixToolset.Core/BindContext.cs
index 1c1f7528..50ccdec6 100644
--- a/src/wix/WixToolset.Core/BindContext.cs
+++ b/src/wix/WixToolset.Core/BindContext.cs
@@ -42,6 +42,8 @@ namespace WixToolset.Core
42 42
43 public string OutputPath { get; set; } 43 public string OutputPath { get; set; }
44 44
45 public string OutputType { get; set; }
46
45 public PdbType PdbType { get; set; } 47 public PdbType PdbType { get; set; }
46 48
47 public string PdbPath { get; set; } 49 public string PdbPath { get; set; }
diff --git a/src/wix/WixToolset.Core/Binder.cs b/src/wix/WixToolset.Core/Binder.cs
index 204ab6ee..fd6e1470 100644
--- a/src/wix/WixToolset.Core/Binder.cs
+++ b/src/wix/WixToolset.Core/Binder.cs
@@ -58,18 +58,27 @@ namespace WixToolset.Core
58 58
59 var backendFactories = extensionManager.GetServices<IBackendFactory>(); 59 var backendFactories = extensionManager.GetServices<IBackendFactory>();
60 60
61 var entrySection = context.IntermediateRepresentation.Sections.First(); 61 var outputType = context is BindContext bindContext ? bindContext.OutputType : null;
62
63 if (String.IsNullOrEmpty(outputType))
64 {
65 var entrySection = context.IntermediateRepresentation.Sections.First();
66
67 outputType = entrySection.Type.ToString();
68 }
62 69
63 foreach (var factory in backendFactories) 70 foreach (var factory in backendFactories)
64 { 71 {
65 if (factory.TryCreateBackend(entrySection.Type.ToString(), context.OutputPath, out var backend)) 72 if (factory.TryCreateBackend(outputType, context.OutputPath, out var backend))
66 { 73 {
67 var result = backend.Bind(context); 74 var result = backend.Bind(context);
68 return result; 75 return result;
69 } 76 }
70 } 77 }
71 78
72 // TODO: messaging that a backend could not be found to bind the output type? 79 var messaging = context.ServiceProvider.GetService<IMessaging>();
80
81 messaging.Write(CoreErrors.BackendNotFound(outputType, context.OutputPath));
73 82
74 return null; 83 return null;
75 } 84 }
diff --git a/src/wix/WixToolset.Core/CommandLine/BuildCommand.cs b/src/wix/WixToolset.Core/CommandLine/BuildCommand.cs
index 965280d0..9ed68d81 100644
--- a/src/wix/WixToolset.Core/CommandLine/BuildCommand.cs
+++ b/src/wix/WixToolset.Core/CommandLine/BuildCommand.cs
@@ -316,6 +316,11 @@ namespace WixToolset.Core.CommandLine
316 context.PdbPath = inputsOutputs.PdbPath; 316 context.PdbPath = inputsOutputs.PdbPath;
317 context.CancellationToken = cancellationToken; 317 context.CancellationToken = cancellationToken;
318 318
319 if (context is BindContext bindContext)
320 {
321 bindContext.OutputType = this.commandLine.OutputType;
322 }
323
319 var binder = this.ServiceProvider.GetService<IBinder>(); 324 var binder = this.ServiceProvider.GetService<IBinder>();
320 bindResult = binder.Bind(context); 325 bindResult = binder.Bind(context);
321 } 326 }
diff --git a/src/wix/WixToolset.Core/CoreErrors.cs b/src/wix/WixToolset.Core/CoreErrors.cs
index 6dbd6c88..16feb9dc 100644
--- a/src/wix/WixToolset.Core/CoreErrors.cs
+++ b/src/wix/WixToolset.Core/CoreErrors.cs
@@ -26,6 +26,11 @@ namespace WixToolset.Core
26 return Message(sourceLineNumbers, Ids.UnableToOpenFile, "Unable to open file: {0}. Error detail: {1}", path, detail); 26 return Message(sourceLineNumbers, Ids.UnableToOpenFile, "Unable to open file: {0}. Error detail: {1}", path, detail);
27 } 27 }
28 28
29 public static Message BackendNotFound(string outputType, string outputPath)
30 {
31 return Message(null, Ids.BackendNotFound, "Unable to find a backend to process output type: {0} for output file: {1}. Specify a different output type or output file extension.", outputType, outputPath);
32 }
33
29 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) 34 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
30 { 35 {
31 return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); 36 return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args);
@@ -37,6 +42,7 @@ namespace WixToolset.Core
37 UnableToDeleteFile = 7011, 42 UnableToDeleteFile = 7011,
38 UnableToMoveFile = 7012, 43 UnableToMoveFile = 7012,
39 UnableToOpenFile = 7013, 44 UnableToOpenFile = 7013,
45 BackendNotFound = 7014,
40 } // last available is 7099. 7100 is WindowsInstallerBackendWarnings. 46 } // last available is 7099. 7100 is WindowsInstallerBackendWarnings.
41 } 47 }
42} 48}
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs
index f571d13b..ce28faff 100644
--- a/src/wix/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs
@@ -222,6 +222,39 @@ namespace WixToolsetTest.CoreIntegration
222 } 222 }
223 223
224 [Fact] 224 [Fact]
225 public void CannotBuildWithUnknownOutputType()
226 {
227 var folder = TestData.Get(@"TestData");
228
229 using (var fs = new DisposableFileSystem())
230 {
231 var baseFolder = fs.GetFolder();
232 var intermediateFolder = Path.Combine(baseFolder, "obj");
233 var outputPath = Path.Combine(intermediateFolder, @"test.pkg");
234
235 var result = WixRunner.Execute(new[]
236 {
237 "build",
238 Path.Combine(folder, "SimplePackage", "SimplePackage.wxs"),
239 "-intermediateFolder", intermediateFolder,
240 "-bindpath", Path.Combine(folder, ".Data"),
241 "-outputType", "invalid",
242 "-o", outputPath,
243 });
244
245 var messages = result.Messages.Select(m => m.ToString()).ToList();
246 messages.Sort();
247
248 WixAssert.CompareLineByLine(new[]
249 {
250 @"Unable to find a backend to process output type: invalid for output file: <folder>\test.pkg. Specify a different output type or output file extension.",
251 }, messages.Select(s => s.Replace(intermediateFolder, "<folder>")).ToArray());
252
253 Assert.Equal(7014, result.ExitCode);
254 }
255 }
256
257 [Fact]
225 public void GuardsAgainstVariousBundleValuesFromLoc() 258 public void GuardsAgainstVariousBundleValuesFromLoc()
226 { 259 {
227 var folder = TestData.Get(@"TestData"); 260 var folder = TestData.Get(@"TestData");