Update all MSBuild tests to run on x86 and x64 MSBuild.
Sean Hall committed
May 30, 2020 at 18:56 UTC
0fbada441640a27352935edc43e1ea16c7a4d8f8
3 files changed
+114
-69
src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs
+58
-55
@@ -11,10 +11,10 @@ namespace WixToolsetTest.MSBuild
11
12
public class MsbuildFixture
13
{
14
- private static readonly string WixPropsPath = Path.Combine(new Uri(typeof(MsbuildFixture).Assembly.CodeBase).AbsolutePath, "..", "..", "publish", "WixToolset.MSBuild", "build", "WixToolset.MSBuild.props");
15
-
16
- [Fact]
17
- public void CanBuildSimpleBundle()
14
+ [Theory]
15
+ [InlineData(BuildSystem.MSBuild)]
16
+ [InlineData(BuildSystem.MSBuild64)]
17
+ public void CanBuildSimpleBundle(BuildSystem buildSystem)
18
{
19
var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage");
20
@@ -25,10 +25,7 @@ namespace WixToolsetTest.MSBuild
25
var binFolder = Path.Combine(baseFolder, @"bin\");
26
var projectPath = Path.Combine(baseFolder, "SimpleBundle.wixproj");
27
28
- var result = MsbuildRunner.Execute(projectPath, new[]
29
- {
30
- $"-p:WixMSBuildProps={WixPropsPath}",
31
- });
28
+ var result = MsbuildUtilities.BuildProject(buildSystem, projectPath);
29
result.AssertSuccess();
30
31
var platformSwitches = result.Output.Where(line => line.TrimStart().StartsWith("wix.exe build -platform x86"));
@@ -49,8 +46,10 @@ namespace WixToolsetTest.MSBuild
46
}
47
}
48
52
- [Fact]
53
- public void CanBuildSimpleMsiPackage()
49
+ [Theory]
50
+ [InlineData(BuildSystem.MSBuild)]
51
+ [InlineData(BuildSystem.MSBuild64)]
52
+ public void CanBuildSimpleMsiPackage(BuildSystem buildSystem)
53
{
54
var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
55
@@ -61,10 +60,7 @@ namespace WixToolsetTest.MSBuild
60
var binFolder = Path.Combine(baseFolder, @"bin\");
61
var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");
62
64
- var result = MsbuildRunner.Execute(projectPath, new[]
65
- {
66
- $"-p:WixMSBuildProps={WixPropsPath}",
67
- });
63
+ var result = MsbuildUtilities.BuildProject(buildSystem, projectPath);
64
result.AssertSuccess();
65
66
var platformSwitches = result.Output.Where(line => line.TrimStart().StartsWith("wix.exe build -platform x86"));
@@ -86,8 +82,10 @@ namespace WixToolsetTest.MSBuild
82
}
83
}
84
89
- [Fact]
90
- public void CanBuildWithDefaultAndExplicitlyFullWixpdbs()
85
+ [Theory]
86
+ [InlineData(BuildSystem.MSBuild)]
87
+ [InlineData(BuildSystem.MSBuild64)]
88
+ public void CanBuildWithDefaultAndExplicitlyFullWixpdbs(BuildSystem buildSystem)
89
{
90
var expectedOutputs = new[]
91
{
@@ -96,21 +94,23 @@ namespace WixToolsetTest.MSBuild
94
@"bin\x86\Debug\en-US\MsiPackage.wixpdb",
95
};
96
99
- this.AssertWixpdb(null, expectedOutputs);
100
- this.AssertWixpdb("Full", expectedOutputs);
97
+ this.AssertWixpdb(buildSystem, null, expectedOutputs);
98
+ this.AssertWixpdb(buildSystem, "Full", expectedOutputs);
99
}
100
103
- [Fact]
104
- public void CanBuildWithNoWixpdb()
101
+ [Theory]
102
+ [InlineData(BuildSystem.MSBuild)]
103
+ [InlineData(BuildSystem.MSBuild64)]
104
+ public void CanBuildWithNoWixpdb(BuildSystem buildSystem)
105
{
106
- this.AssertWixpdb("NONE", new[]
106
+ this.AssertWixpdb(buildSystem, "NONE", new[]
107
{
108
@"bin\x86\Debug\en-US\cab1.cab",
109
@"bin\x86\Debug\en-US\MsiPackage.msi",
110
});
111
}
112
113
- private void AssertWixpdb(string wixpdbType, string[] expectedOutputFiles)
113
+ private void AssertWixpdb(BuildSystem buildSystem, string wixpdbType, string[] expectedOutputFiles)
114
{
115
var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
116
@@ -121,10 +121,9 @@ namespace WixToolsetTest.MSBuild
121
var binFolder = Path.Combine(baseFolder, @"bin\");
122
var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");
123
124
- var result = MsbuildRunner.Execute(projectPath, new[]
124
+ var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
125
{
126
wixpdbType == null ? String.Empty : $"-p:WixPdbType={wixpdbType}",
127
- $"-p:WixMSBuildProps={WixPropsPath}",
127
});
128
result.AssertSuccess();
129
@@ -136,8 +135,10 @@ namespace WixToolsetTest.MSBuild
135
}
136
}
137
139
- [Fact]
140
- public void CanBuild64BitMsiPackage()
138
+ [Theory]
139
+ [InlineData(BuildSystem.MSBuild)]
140
+ [InlineData(BuildSystem.MSBuild64)]
141
+ public void CanBuild64BitMsiPackage(BuildSystem buildSystem)
142
{
143
var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
144
@@ -148,10 +149,9 @@ namespace WixToolsetTest.MSBuild
149
var binFolder = Path.Combine(baseFolder, @"bin\");
150
var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");
151
151
- var result = MsbuildRunner.Execute(projectPath, new[]
152
+ var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
153
{
153
- $"-p:WixMSBuildProps={WixPropsPath}",
154
- $"-p:InstallerPlatform=x64",
154
+ $"-p:Platform=x64",
155
});
156
result.AssertSuccess();
157
@@ -164,15 +164,17 @@ namespace WixToolsetTest.MSBuild
164
.ToArray();
165
Assert.Equal(new[]
166
{
167
- @"bin\x86\Debug\en-US\cab1.cab",
168
- @"bin\x86\Debug\en-US\MsiPackage.msi",
169
- @"bin\x86\Debug\en-US\MsiPackage.wixpdb",
167
+ @"bin\x64\Debug\en-US\cab1.cab",
168
+ @"bin\x64\Debug\en-US\MsiPackage.msi",
169
+ @"bin\x64\Debug\en-US\MsiPackage.wixpdb",
170
}, paths);
171
}
172
}
173
174
- [Fact(Skip = "Currently fails")]
175
- public void CanBuildSimpleMsiPackageWithIceSuppressions()
174
+ [Theory(Skip = "Currently fails")]
175
+ [InlineData(BuildSystem.MSBuild)]
176
+ [InlineData(BuildSystem.MSBuild64)]
177
+ public void CanBuildSimpleMsiPackageWithIceSuppressions(BuildSystem buildSystem)
178
{
179
var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
180
@@ -183,17 +185,18 @@ namespace WixToolsetTest.MSBuild
185
var binFolder = Path.Combine(baseFolder, @"bin\");
186
var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");
187
186
- var result = MsbuildRunner.Execute(projectPath, new[]
188
+ var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
189
{
188
- $"-p:WixMSBuildProps={WixPropsPath}",
189
- "-p:SuppressIces=\"ICE45;ICE46\""
190
+ "-p:SuppressIces=\"ICE45;ICE46\"",
191
});
192
result.AssertSuccess();
193
}
194
}
195
195
- [Fact]
196
- public void CanBuildSimpleMsiPackageWithWarningSuppressions()
196
+ [Theory]
197
+ [InlineData(BuildSystem.MSBuild)]
198
+ [InlineData(BuildSystem.MSBuild64)]
199
+ public void CanBuildSimpleMsiPackageWithWarningSuppressions(BuildSystem buildSystem)
200
{
201
var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
202
@@ -204,10 +207,9 @@ namespace WixToolsetTest.MSBuild
207
var binFolder = Path.Combine(baseFolder, @"bin\");
208
var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");
209
207
- var result = MsbuildRunner.Execute(projectPath, new[]
210
+ var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
211
{
209
- $"-p:WixMSBuildProps={WixPropsPath}",
210
- "-p:SuppressSpecificWarnings=\"1118;1102\""
212
+ "-p:SuppressSpecificWarnings=\"1118;1102\"",
213
});
214
result.AssertSuccess();
215
@@ -216,8 +218,10 @@ namespace WixToolsetTest.MSBuild
218
}
219
}
220
219
- [Fact]
220
- public void CanBuildSimpleMsiPackageAsWixipl()
221
+ [Theory]
222
+ [InlineData(BuildSystem.MSBuild)]
223
+ [InlineData(BuildSystem.MSBuild64)]
224
+ public void CanBuildSimpleMsiPackageAsWixipl(BuildSystem buildSystem)
225
{
226
var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
227
@@ -228,10 +232,9 @@ namespace WixToolsetTest.MSBuild
232
var binFolder = Path.Combine(baseFolder, @"bin\");
233
var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");
234
231
- var result = MsbuildRunner.Execute(projectPath, new[]
235
+ var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
236
{
233
- $"-p:WixMSBuildProps={WixPropsPath}",
234
- "-p:OutputType=IntermediatePostLink"
237
+ "-p:OutputType=IntermediatePostLink",
238
});
239
result.AssertSuccess();
240
@@ -242,8 +245,10 @@ namespace WixToolsetTest.MSBuild
245
}
246
}
247
245
- [Fact]
246
- public void CanBuildAndCleanSimpleMsiPackage()
248
+ [Theory]
249
+ [InlineData(BuildSystem.MSBuild)]
250
+ [InlineData(BuildSystem.MSBuild64)]
251
+ public void CanBuildAndCleanSimpleMsiPackage(BuildSystem buildSystem)
252
{
253
var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
254
@@ -254,10 +259,9 @@ namespace WixToolsetTest.MSBuild
259
var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");
260
261
// Build
257
- var result = MsbuildRunner.Execute(projectPath, new[]
262
+ var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
263
{
259
- $"-p:WixMSBuildProps={WixPropsPath}",
260
- "-v:diag"
264
+ "-v:diag",
265
});
266
result.AssertSuccess();
267
@@ -270,11 +274,10 @@ namespace WixToolsetTest.MSBuild
274
Assert.NotEmpty(createdPaths);
275
276
// Clean
273
- result = MsbuildRunner.Execute(projectPath, new[]
277
+ result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
278
{
275
- $"-p:WixMSBuildProps={WixPropsPath}",
279
"-t:Clean",
277
- "-v:diag"
280
+ "-v:diag",
281
});
282
result.AssertSuccess();
283
src/test/WixToolsetTest.MSBuild/MsbuildHeatFixture.cs
+10
-14
@@ -13,10 +13,10 @@ namespace WixToolsetTest.MSBuild
13
14
public class MsbuildHeatFixture
15
{
16
- private static readonly string WixPropsPath = Path.Combine(new Uri(typeof(MsbuildHeatFixture).Assembly.CodeBase).AbsolutePath, "..", "..", "publish", "WixToolset.MSBuild", "build", "WixToolset.MSBuild.props");
17
-
18
- [Fact]
19
- public void CanBuildHeatFilePackage()
16
+ [Theory]
17
+ [InlineData(BuildSystem.MSBuild)]
18
+ [InlineData(BuildSystem.MSBuild64)]
19
+ public void CanBuildHeatFilePackage(BuildSystem buildSystem)
20
{
21
var sourceFolder = TestData.Get(@"TestData\HeatFilePackage");
22
@@ -28,10 +28,7 @@ namespace WixToolsetTest.MSBuild
28
var intermediateFolder = Path.Combine(baseFolder, @"obj\");
29
var projectPath = Path.Combine(baseFolder, "HeatFilePackage.wixproj");
30
31
- var result = MsbuildRunner.Execute(projectPath, new[]
32
- {
33
- $"-p:WixMSBuildProps={WixPropsPath}",
34
- });
31
+ var result = MsbuildUtilities.BuildProject(buildSystem, projectPath);
32
result.AssertSuccess();
33
34
var heatCommandLines = result.Output.Where(line => line.TrimStart().StartsWith("heat.exe file"));
@@ -71,8 +68,10 @@ namespace WixToolsetTest.MSBuild
68
}
69
}
70
74
- [Fact]
75
- public void CanBuildHeatFileWithMultipleFilesPackage()
71
+ [Theory]
72
+ [InlineData(BuildSystem.MSBuild)]
73
+ [InlineData(BuildSystem.MSBuild64)]
74
+ public void CanBuildHeatFileWithMultipleFilesPackage(BuildSystem buildSystem)
75
{
76
var sourceFolder = TestData.Get(@"TestData\HeatFileMultipleFilesSameFileName");
77
@@ -84,10 +83,7 @@ namespace WixToolsetTest.MSBuild
83
var intermediateFolder = Path.Combine(baseFolder, @"obj\");
84
var projectPath = Path.Combine(baseFolder, "HeatFileMultipleFilesSameFileName.wixproj");
85
87
- var result = MsbuildRunner.Execute(projectPath, new[]
88
- {
89
- $"-p:WixMSBuildProps={WixPropsPath}",
90
- });
86
+ var result = MsbuildUtilities.BuildProject(buildSystem, projectPath);
87
result.AssertSuccess();
88
89
var heatCommandLines = result.Output.Where(line => line.TrimStart().StartsWith("heat.exe file"));
src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs
new
+46
@@ -0,0 +1,46 @@
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 WixToolsetTest.MSBuild
4
+{
5
+ using System;
6
+ using System.Collections.Generic;
7
+ using System.IO;
8
+ using WixBuildTools.TestSupport;
9
+
10
+ public enum BuildSystem
11
+ {
12
+ MSBuild,
13
+ MSBuild64,
14
+ }
15
+
16
+ public static class MsbuildUtilities
17
+ {
18
+ public static readonly string WixPropsPath = Path.Combine(new Uri(typeof(MsbuildUtilities).Assembly.CodeBase).AbsolutePath, "..", "..", "publish", "WixToolset.MSBuild", "build", "WixToolset.MSBuild.props");
19
+
20
+ public static MsbuildRunnerResult BuildProject(BuildSystem buildSystem, string projectPath, params string[] arguments)
21
+ {
22
+ var allArgs = new List<string>
23
+ {
24
+ $"-p:WixMSBuildProps={MsbuildUtilities.WixPropsPath}",
25
+ };
26
+
27
+ if (arguments != null)
28
+ {
29
+ allArgs.AddRange(arguments);
30
+ }
31
+
32
+ switch (buildSystem)
33
+ {
34
+ case BuildSystem.MSBuild:
35
+ case BuildSystem.MSBuild64:
36
+ {
37
+ return MsbuildRunner.Execute(projectPath, allArgs.ToArray(), buildSystem == BuildSystem.MSBuild64);
38
+ }
39
+ default:
40
+ {
41
+ throw new NotImplementedException();
42
+ }
43
+ }
44
+ }
45
+ }
46
+}