aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Bal/test
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-04-19 17:15:05 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-04-19 18:35:15 -0500
commit57fd164d56466a52854e825afd5fdc2b6b97f12a (patch)
tree7d4ace6d7a55c2a50302e3b6866456026a2c6222 /src/ext/Bal/test
parent6435d26c7e2ce54ec38d0cc9eb4d2cb10e9614e0 (diff)
downloadwix-57fd164d56466a52854e825afd5fdc2b6b97f12a.tar.gz
wix-57fd164d56466a52854e825afd5fdc2b6b97f12a.tar.bz2
wix-57fd164d56466a52854e825afd5fdc2b6b97f12a.zip
Replace Dnc.Host with Dnc.HostGenerator to support linker trimming.
Diffstat (limited to 'src/ext/Bal/test')
-rw-r--r--src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs45
-rw-r--r--src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs88
-rw-r--r--src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/WixToolsetTest.Dnc.HostGenerator.csproj27
-rw-r--r--src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs153
-rw-r--r--src/ext/Bal/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs66
-rw-r--r--src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs3
-rw-r--r--src/ext/Bal/test/examples/Directory.Build.props3
-rw-r--r--src/ext/Bal/test/examples/Directory.Build.targets3
-rw-r--r--src/ext/Bal/test/examples/Directory.csproj.props5
-rw-r--r--src/ext/Bal/test/examples/Directory.wixproj.props (renamed from src/ext/Bal/test/examples/Wix.Build.props)0
-rw-r--r--src/ext/Bal/test/examples/Directory.wixproj.targets (renamed from src/ext/Bal/test/examples/Wix.Build.targets)0
-rw-r--r--src/ext/Bal/test/examples/DncBA.targets19
-rw-r--r--src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj10
-rw-r--r--src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj13
-rw-r--r--src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj16
-rw-r--r--src/ext/Bal/test/examples/examples.proj7
16 files changed, 320 insertions, 138 deletions
diff --git a/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs
new file mode 100644
index 00000000..27729ac8
--- /dev/null
+++ b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs
@@ -0,0 +1,45 @@
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
3namespace WixToolsetTest.Dnc.HostGenerator
4{
5 using System;
6 using System.Collections.Immutable;
7 using Microsoft.CodeAnalysis;
8 using Microsoft.CodeAnalysis.CSharp;
9 using Microsoft.CodeAnalysis.CSharp.Testing;
10 using Microsoft.CodeAnalysis.Testing.Verifiers;
11
12 public static class CSharpSourceGeneratorVerifier<TSourceGenerator>
13 where TSourceGenerator : ISourceGenerator, new()
14 {
15 public class Test : CSharpSourceGeneratorTest<TSourceGenerator, XUnitVerifier>
16 {
17 public Test()
18 {
19 }
20
21 protected override CompilationOptions CreateCompilationOptions()
22 {
23 var compilationOptions = base.CreateCompilationOptions();
24 return compilationOptions.WithSpecificDiagnosticOptions(
25 compilationOptions.SpecificDiagnosticOptions.SetItems(GetNullableWarningsFromCompiler()));
26 }
27
28 public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Default;
29
30 private static ImmutableDictionary<string, ReportDiagnostic> GetNullableWarningsFromCompiler()
31 {
32 string[] args = { "/warnaserror:nullable" };
33 var commandLineArguments = CSharpCommandLineParser.Default.Parse(args, baseDirectory: Environment.CurrentDirectory, sdkDirectory: Environment.CurrentDirectory);
34 var nullableWarnings = commandLineArguments.CompilationOptions.SpecificDiagnosticOptions;
35
36 return nullableWarnings;
37 }
38
39 protected override ParseOptions CreateParseOptions()
40 {
41 return ((CSharpParseOptions)base.CreateParseOptions()).WithLanguageVersion(this.LanguageVersion);
42 }
43 }
44 }
45}
diff --git a/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs
new file mode 100644
index 00000000..6ede1089
--- /dev/null
+++ b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs
@@ -0,0 +1,88 @@
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
3namespace WixToolsetTest.Dnc.HostGenerator
4{
5 using System;
6 using System.Text;
7 using System.Threading.Tasks;
8 using Microsoft.CodeAnalysis;
9 using Microsoft.CodeAnalysis.Testing;
10 using Microsoft.CodeAnalysis.Text;
11 using WixToolset.Dnc.HostGenerator;
12 using WixToolset.Mba.Core;
13 using Xunit;
14
15 using VerifyCS = CSharpSourceGeneratorVerifier<WixToolset.Dnc.HostGenerator.DncHostGenerator>;
16
17 public class DncHostGeneratorTests
18 {
19 static readonly MetadataReference MbaCoreAssembly = MetadataReference.CreateFromFile(typeof(BootstrapperApplicationFactoryAttribute).Assembly.Location);
20
21 [Fact]
22 public async Task FailsBuildWhenMissingAttribute()
23 {
24 var code = @"
25//[assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Test.BAFactory))]
26namespace Test
27{
28 using WixToolset.Mba.Core;
29
30 public class BAFactory : BaseBootstrapperApplicationFactory
31 {
32 protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand)
33 {
34 return null;
35 }
36 }
37}
38";
39
40 await new VerifyCS.Test
41 {
42 TestState =
43 {
44 Sources = { code },
45 AdditionalReferences = { MbaCoreAssembly },
46 ExpectedDiagnostics =
47 {
48 new DiagnosticResult(DncHostGenerator.MissingFactoryAttributeDescriptor),
49 },
50 },
51 }.RunAsync();
52 }
53
54 [Fact]
55 public async Task GeneratesEntryPoint()
56 {
57 var code = @"
58[assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Test.BAFactory))]
59namespace Test
60{
61 using WixToolset.Mba.Core;
62
63 public class BAFactory : BaseBootstrapperApplicationFactory
64 {
65 protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand)
66 {
67 return null;
68 }
69 }
70}
71";
72 var generated = String.Format(DncHostGenerator.Template, DncHostGenerator.Version, "Test.BAFactory");
73
74 await new VerifyCS.Test
75 {
76 TestState =
77 {
78 Sources = { code },
79 GeneratedSources =
80 {
81 (typeof(DncHostGenerator), "WixToolset.Dnc.Host.g.cs", SourceText.From(generated, Encoding.UTF8, SourceHashAlgorithm.Sha256)),
82 },
83 AdditionalReferences = { MbaCoreAssembly },
84 },
85 }.RunAsync();
86 }
87 }
88}
diff --git a/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/WixToolsetTest.Dnc.HostGenerator.csproj b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/WixToolsetTest.Dnc.HostGenerator.csproj
new file mode 100644
index 00000000..0c2b33fd
--- /dev/null
+++ b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/WixToolsetTest.Dnc.HostGenerator.csproj
@@ -0,0 +1,27 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3
4<Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 <TargetFramework>netcoreapp3.1</TargetFramework>
7 <IsPackable>false</IsPackable>
8 <SignOutput>false</SignOutput>
9 </PropertyGroup>
10
11 <ItemGroup>
12 <ProjectReference Include="..\..\WixToolset.Dnc.HostGenerator\WixToolset.Dnc.HostGenerator.csproj" />
13 </ItemGroup>
14
15 <ItemGroup>
16 <PackageReference Include="WixBuildTools.TestSupport" />
17 <PackageReference Include="WixToolset.Mba.Core" />
18 </ItemGroup>
19
20 <ItemGroup>
21 <PackageReference Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" />
22 <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
23 <PackageReference Include="Microsoft.NET.Test.Sdk" />
24 <PackageReference Include="xunit" />
25 <PackageReference Include="xunit.runner.visualstudio" PrivateAssets="All" />
26 </ItemGroup>
27</Project>
diff --git a/src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs b/src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs
index 8dd5ff11..14b80fe8 100644
--- a/src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs
+++ b/src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs
@@ -2,9 +2,7 @@
2 2
3namespace WixToolsetTest.ManagedHost 3namespace WixToolsetTest.ManagedHost
4{ 4{
5 using System.IO;
6 using WixBuildTools.TestSupport; 5 using WixBuildTools.TestSupport;
7 using WixToolset.Core.TestPackage;
8 using Xunit; 6 using Xunit;
9 7
10 public class DncHostFixture 8 public class DncHostFixture
@@ -21,11 +19,13 @@ namespace WixToolsetTest.ManagedHost
21 var testEngine = new TestEngine(); 19 var testEngine = new TestEngine();
22 20
23 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); 21 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
24 var logMessages = result.Output; 22 WixAssert.CompareLineByLine(new[]
25 Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[0]); 23 {
26 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 24 "Loading .NET Core FDD bootstrapper application.",
27 Assert.Equal("EarliestCoreBA", logMessages[2]); 25 "Creating BA thread to run asynchronously.",
28 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 26 "EarliestCoreBA",
27 "Shutdown,ReloadBootstrapper,0",
28 }, result.Output.ToArray());
29 } 29 }
30 } 30 }
31 31
@@ -39,14 +39,17 @@ namespace WixToolsetTest.ManagedHost
39 var testEngine = new TestEngine(); 39 var testEngine = new TestEngine();
40 40
41 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); 41 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
42 var logMessages = result.Output; 42 WixAssert.CompareLineByLine(new[]
43 Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]); 43 {
44 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 44 "Loading .NET Core SCD bootstrapper application.",
45 Assert.Equal("EarliestCoreBA", logMessages[2]); 45 "Creating BA thread to run asynchronously.",
46 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 46 "EarliestCoreBA",
47 "Shutdown,ReloadBootstrapper,0",
48 }, result.Output.ToArray());
47 } 49 }
48 } 50 }
49 51
52 [Fact]
50 public void CanLoadTrimmedSCDEarliestCoreMBA() 53 public void CanLoadTrimmedSCDEarliestCoreMBA()
51 { 54 {
52 using (var fs = new DisposableFileSystem()) 55 using (var fs = new DisposableFileSystem())
@@ -56,11 +59,13 @@ namespace WixToolsetTest.ManagedHost
56 var testEngine = new TestEngine(); 59 var testEngine = new TestEngine();
57 60
58 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); 61 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
59 var logMessages = result.Output; 62 WixAssert.CompareLineByLine(new[]
60 Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]); 63 {
61 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 64 "Loading .NET Core SCD bootstrapper application.",
62 Assert.Equal("EarliestCoreBA", logMessages[2]); 65 "Creating BA thread to run asynchronously.",
63 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 66 "EarliestCoreBA",
67 "Shutdown,ReloadBootstrapper,0",
68 }, result.Output.ToArray());
64 } 69 }
65 } 70 }
66 71
@@ -74,16 +79,19 @@ namespace WixToolsetTest.ManagedHost
74 var testEngine = new TestEngine(); 79 var testEngine = new TestEngine();
75 80
76 var result = testEngine.RunReloadEngine(bundleFile, baseFolder); 81 var result = testEngine.RunReloadEngine(bundleFile, baseFolder);
77 var logMessages = result.Output; 82 WixAssert.CompareLineByLine(new[]
78 Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]); 83 {
79 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 84 "Loading .NET Core SCD bootstrapper application.",
80 Assert.Equal("EarliestCoreBA", logMessages[2]); 85 "Creating BA thread to run asynchronously.",
81 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 86 "EarliestCoreBA",
82 Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[4]); 87 "Shutdown,ReloadBootstrapper,0",
83 Assert.Equal("Reloaded 1 time(s)", logMessages[5]); // dnchost doesn't currently support unloading 88 "Loading .NET Core SCD bootstrapper application.",
84 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[6]); 89 "Reloaded 1 time(s)", // dnchost doesn't currently support unloading
85 Assert.Equal("EarliestCoreBA", logMessages[7]); 90 "Creating BA thread to run asynchronously.",
86 Assert.Equal("Shutdown,Restart,0", logMessages[8]); 91 "EarliestCoreBA",
92 "Shutdown,Restart,0",
93
94 }, result.Output.ToArray());
87 } 95 }
88 } 96 }
89 97
@@ -97,11 +105,13 @@ namespace WixToolsetTest.ManagedHost
97 var testEngine = new TestEngine(); 105 var testEngine = new TestEngine();
98 106
99 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); 107 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
100 var logMessages = result.Output; 108 WixAssert.CompareLineByLine(new[]
101 Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[0]); 109 {
102 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 110 "Loading .NET Core FDD bootstrapper application.",
103 Assert.Equal("LatestCoreBA", logMessages[2]); 111 "Creating BA thread to run asynchronously.",
104 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 112 "LatestCoreBA",
113 "Shutdown,ReloadBootstrapper,0",
114 }, result.Output.ToArray());
105 } 115 }
106 } 116 }
107 117
@@ -115,16 +125,18 @@ namespace WixToolsetTest.ManagedHost
115 var testEngine = new TestEngine(); 125 var testEngine = new TestEngine();
116 126
117 var result = testEngine.RunReloadEngine(bundleFile, baseFolder); 127 var result = testEngine.RunReloadEngine(bundleFile, baseFolder);
118 var logMessages = result.Output; 128 WixAssert.CompareLineByLine(new[]
119 Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[0]); 129 {
120 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 130 "Loading .NET Core FDD bootstrapper application.",
121 Assert.Equal("LatestCoreBA", logMessages[2]); 131 "Creating BA thread to run asynchronously.",
122 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 132 "LatestCoreBA",
123 Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[4]); 133 "Shutdown,ReloadBootstrapper,0",
124 Assert.Equal("Reloaded 1 time(s)", logMessages[5]); // dnchost doesn't currently support unloading 134 "Loading .NET Core FDD bootstrapper application.",
125 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[6]); 135 "Reloaded 1 time(s)", // dnchost doesn't currently support unloading
126 Assert.Equal("LatestCoreBA", logMessages[7]); 136 "Creating BA thread to run asynchronously.",
127 Assert.Equal("Shutdown,Restart,0", logMessages[8]); 137 "LatestCoreBA",
138 "Shutdown,Restart,0",
139 }, result.Output.ToArray());
128 } 140 }
129 } 141 }
130 142
@@ -138,11 +150,14 @@ namespace WixToolsetTest.ManagedHost
138 var testEngine = new TestEngine(); 150 var testEngine = new TestEngine();
139 151
140 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); 152 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
153 WixAssert.CompareLineByLine(new[]
154 {
155 "Loading .NET Core SCD bootstrapper application.",
156 "Creating BA thread to run asynchronously.",
157 "LatestCoreBA",
158 "Shutdown,ReloadBootstrapper,0",
159 }, result.Output.ToArray());
141 var logMessages = result.Output; 160 var logMessages = result.Output;
142 Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]);
143 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]);
144 Assert.Equal("LatestCoreBA", logMessages[2]);
145 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]);
146 } 161 }
147 } 162 }
148 163
@@ -156,11 +171,13 @@ namespace WixToolsetTest.ManagedHost
156 var testEngine = new TestEngine(); 171 var testEngine = new TestEngine();
157 172
158 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); 173 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
159 var logMessages = result.Output; 174 WixAssert.CompareLineByLine(new[]
160 Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]); 175 {
161 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 176 "Loading .NET Core SCD bootstrapper application.",
162 Assert.Equal("LatestCoreBA", logMessages[2]); 177 "Creating BA thread to run asynchronously.",
163 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 178 "LatestCoreBA",
179 "Shutdown,ReloadBootstrapper,0",
180 }, result.Output.ToArray());
164 } 181 }
165 } 182 }
166 183
@@ -174,16 +191,18 @@ namespace WixToolsetTest.ManagedHost
174 var testEngine = new TestEngine(); 191 var testEngine = new TestEngine();
175 192
176 var result = testEngine.RunReloadEngine(bundleFile, baseFolder); 193 var result = testEngine.RunReloadEngine(bundleFile, baseFolder);
177 var logMessages = result.Output; 194 WixAssert.CompareLineByLine(new[]
178 Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[0]); 195 {
179 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 196 "Loading .NET Core SCD bootstrapper application.",
180 Assert.Equal("LatestCoreBA", logMessages[2]); 197 "Creating BA thread to run asynchronously.",
181 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 198 "LatestCoreBA",
182 Assert.Equal("Loading .NET Core SCD bootstrapper application.", logMessages[4]); 199 "Shutdown,ReloadBootstrapper,0",
183 Assert.Equal("Reloaded 1 time(s)", logMessages[5]); // dnchost doesn't currently support unloading 200 "Loading .NET Core SCD bootstrapper application.",
184 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[6]); 201 "Reloaded 1 time(s)", // dnchost doesn't currently support unloading
185 Assert.Equal("LatestCoreBA", logMessages[7]); 202 "Creating BA thread to run asynchronously.",
186 Assert.Equal("Shutdown,Restart,0", logMessages[8]); 203 "LatestCoreBA",
204 "Shutdown,Restart,0",
205 }, result.Output.ToArray());
187 } 206 }
188 } 207 }
189 208
@@ -197,11 +216,13 @@ namespace WixToolsetTest.ManagedHost
197 var testEngine = new TestEngine(); 216 var testEngine = new TestEngine();
198 217
199 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); 218 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
200 var logMessages = result.Output; 219 WixAssert.CompareLineByLine(new[]
201 Assert.Equal("Loading .NET Core FDD bootstrapper application.", logMessages[0]); 220 {
202 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 221 "Loading .NET Core FDD bootstrapper application.",
203 Assert.Equal("WPFCoreBA", logMessages[2]); 222 "Creating BA thread to run asynchronously.",
204 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 223 "WPFCoreBA",
224 "Shutdown,ReloadBootstrapper,0",
225 }, result.Output.ToArray());
205 } 226 }
206 } 227 }
207 } 228 }
diff --git a/src/ext/Bal/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs b/src/ext/Bal/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs
index dd37ee58..b4ebe1c6 100644
--- a/src/ext/Bal/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs
+++ b/src/ext/Bal/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs
@@ -2,9 +2,7 @@
2 2
3namespace WixToolsetTest.ManagedHost 3namespace WixToolsetTest.ManagedHost
4{ 4{
5 using System.IO;
6 using WixBuildTools.TestSupport; 5 using WixBuildTools.TestSupport;
7 using WixToolset.Core.TestPackage;
8 using Xunit; 6 using Xunit;
9 7
10 public class MbaHostFixture 8 public class MbaHostFixture
@@ -21,11 +19,13 @@ namespace WixToolsetTest.ManagedHost
21 var testEngine = new TestEngine(); 19 var testEngine = new TestEngine();
22 20
23 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); 21 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
24 var logMessages = result.Output; 22 WixAssert.CompareLineByLine(new[]
25 Assert.Equal("Loading managed bootstrapper application.", logMessages[0]); 23 {
26 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 24 "Loading managed bootstrapper application.",
27 Assert.Equal("FullFramework2BA", logMessages[2]); 25 "Creating BA thread to run asynchronously.",
28 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 26 "FullFramework2BA",
27 "Shutdown,ReloadBootstrapper,0",
28 }, result.Output.ToArray());
29 } 29 }
30 } 30 }
31 31
@@ -39,11 +39,13 @@ namespace WixToolsetTest.ManagedHost
39 var testEngine = new TestEngine(); 39 var testEngine = new TestEngine();
40 40
41 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder); 41 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder);
42 var logMessages = result.Output; 42 WixAssert.CompareLineByLine(new[]
43 Assert.Equal("Loading managed bootstrapper application.", logMessages[0]); 43 {
44 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 44 "Loading managed bootstrapper application.",
45 Assert.Equal("FullFramework4BA", logMessages[2]); 45 "Creating BA thread to run asynchronously.",
46 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 46 "FullFramework4BA",
47 "Shutdown,ReloadBootstrapper,0",
48 }, result.Output.ToArray());
47 } 49 }
48 } 50 }
49 51
@@ -57,15 +59,17 @@ namespace WixToolsetTest.ManagedHost
57 var testEngine = new TestEngine(); 59 var testEngine = new TestEngine();
58 60
59 var result = testEngine.RunReloadEngine(bundleFile, baseFolder); 61 var result = testEngine.RunReloadEngine(bundleFile, baseFolder);
60 var logMessages = result.Output; 62 WixAssert.CompareLineByLine(new[]
61 Assert.Equal("Loading managed bootstrapper application.", logMessages[0]); 63 {
62 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 64 "Loading managed bootstrapper application.",
63 Assert.Equal("FullFramework2BA", logMessages[2]); 65 "Creating BA thread to run asynchronously.",
64 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 66 "FullFramework2BA",
65 Assert.Equal("Loading managed bootstrapper application.", logMessages[4]); 67 "Shutdown,ReloadBootstrapper,0",
66 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[5]); 68 "Loading managed bootstrapper application.",
67 Assert.Equal("FullFramework2BA", logMessages[6]); 69 "Creating BA thread to run asynchronously.",
68 Assert.Equal("Shutdown,Restart,0", logMessages[7]); 70 "FullFramework2BA",
71 "Shutdown,Restart,0",
72 }, result.Output.ToArray());
69 } 73 }
70 } 74 }
71 75
@@ -79,15 +83,17 @@ namespace WixToolsetTest.ManagedHost
79 var testEngine = new TestEngine(); 83 var testEngine = new TestEngine();
80 84
81 var result = testEngine.RunReloadEngine(bundleFile, baseFolder); 85 var result = testEngine.RunReloadEngine(bundleFile, baseFolder);
82 var logMessages = result.Output; 86 WixAssert.CompareLineByLine(new[]
83 Assert.Equal("Loading managed bootstrapper application.", logMessages[0]); 87 {
84 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); 88 "Loading managed bootstrapper application.",
85 Assert.Equal("FullFramework4BA", logMessages[2]); 89 "Creating BA thread to run asynchronously.",
86 Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); 90 "FullFramework4BA",
87 Assert.Equal("Loading managed bootstrapper application.", logMessages[4]); 91 "Shutdown,ReloadBootstrapper,0",
88 Assert.Equal("Creating BA thread to run asynchronously.", logMessages[5]); 92 "Loading managed bootstrapper application.",
89 Assert.Equal("FullFramework4BA", logMessages[6]); 93 "Creating BA thread to run asynchronously.",
90 Assert.Equal("Shutdown,Restart,0", logMessages[7]); 94 "FullFramework4BA",
95 "Shutdown,Restart,0",
96 }, result.Output.ToArray());
91 } 97 }
92 } 98 }
93 } 99 }
diff --git a/src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs b/src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs
index 9d7fc9db..30d97f3e 100644
--- a/src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs
+++ b/src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs
@@ -2,6 +2,7 @@
2 2
3namespace WixToolsetTest.ManagedHost 3namespace WixToolsetTest.ManagedHost
4{ 4{
5 using System;
5 using System.Collections.Generic; 6 using System.Collections.Generic;
6 using System.Diagnostics; 7 using System.Diagnostics;
7 using System.IO; 8 using System.IO;
@@ -41,7 +42,7 @@ namespace WixToolsetTest.ManagedHost
41 { 42 {
42 var startInfo = new ProcessStartInfo(executablePath) 43 var startInfo = new ProcessStartInfo(executablePath)
43 { 44 {
44 Arguments = string.Join(' ', arguments), 45 Arguments = String.Join(' ', arguments),
45 CreateNoWindow = true, 46 CreateNoWindow = true,
46 RedirectStandardError = true, 47 RedirectStandardError = true,
47 RedirectStandardOutput = true, 48 RedirectStandardOutput = true,
diff --git a/src/ext/Bal/test/examples/Directory.Build.props b/src/ext/Bal/test/examples/Directory.Build.props
index 52b931f6..7f38564a 100644
--- a/src/ext/Bal/test/examples/Directory.Build.props
+++ b/src/ext/Bal/test/examples/Directory.Build.props
@@ -2,5 +2,6 @@
2<!-- 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<!-- 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. -->
3<Project> 3<Project>
4 <Import Project="$(MsbuildThisFileDirectory)..\..\Directory.Build.props" /> 4 <Import Project="$(MsbuildThisFileDirectory)..\..\Directory.Build.props" />
5 <Import Project="Wix.Build.props" Condition=" '$(MSBuildProjectExtension)'=='.wixproj' " /> 5 <Import Project="Directory.csproj.props" Condition=" '$(MSBuildProjectExtension)'=='.csproj' " />
6 <Import Project="Directory.wixproj.props" Condition=" '$(MSBuildProjectExtension)'=='.wixproj' " />
6</Project> 7</Project>
diff --git a/src/ext/Bal/test/examples/Directory.Build.targets b/src/ext/Bal/test/examples/Directory.Build.targets
index 35946585..b27a1a41 100644
--- a/src/ext/Bal/test/examples/Directory.Build.targets
+++ b/src/ext/Bal/test/examples/Directory.Build.targets
@@ -2,5 +2,6 @@
2<!-- 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<!-- 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. -->
3<Project> 3<Project>
4 <Import Project="$(MsbuildThisFileDirectory)..\..\..\..\Directory.Build.targets" /> 4 <Import Project="$(MsbuildThisFileDirectory)..\..\..\..\Directory.Build.targets" />
5 <Import Project="Wix.Build.targets" Condition=" '$(MSBuildProjectExtension)'=='.wixproj' " /> 5 <Import Project="Directory.wixproj.targets" Condition=" '$(MSBuildProjectExtension)'=='.wixproj' " />
6 <Import Project="DncBA.targets" Condition=" '$(IsDncBA)'=='true' " />
6</Project> 7</Project>
diff --git a/src/ext/Bal/test/examples/Directory.csproj.props b/src/ext/Bal/test/examples/Directory.csproj.props
new file mode 100644
index 00000000..e314ca20
--- /dev/null
+++ b/src/ext/Bal/test/examples/Directory.csproj.props
@@ -0,0 +1,5 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3<Project>
4 <Import Project="$(MsbuildThisFileDirectory)..\..\WixToolset.Dnc.HostGenerator\build\WixToolset.Dnc.HostGenerator.props" />
5</Project>
diff --git a/src/ext/Bal/test/examples/Wix.Build.props b/src/ext/Bal/test/examples/Directory.wixproj.props
index 78ad462f..78ad462f 100644
--- a/src/ext/Bal/test/examples/Wix.Build.props
+++ b/src/ext/Bal/test/examples/Directory.wixproj.props
diff --git a/src/ext/Bal/test/examples/Wix.Build.targets b/src/ext/Bal/test/examples/Directory.wixproj.targets
index 7e6fe9f2..7e6fe9f2 100644
--- a/src/ext/Bal/test/examples/Wix.Build.targets
+++ b/src/ext/Bal/test/examples/Directory.wixproj.targets
diff --git a/src/ext/Bal/test/examples/DncBA.targets b/src/ext/Bal/test/examples/DncBA.targets
new file mode 100644
index 00000000..2b8c1428
--- /dev/null
+++ b/src/ext/Bal/test/examples/DncBA.targets
@@ -0,0 +1,19 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3<Project>
4 <Import Project="$(MsbuildThisFileDirectory)..\..\WixToolset.Dnc.HostGenerator\build\WixToolset.Dnc.HostGenerator.targets" />
5
6 <PropertyGroup>
7 <ILLinkTreatWarningsAsErrors>false</ILLinkTreatWarningsAsErrors>
8 </PropertyGroup>
9
10 <ItemGroup>
11 <ProjectReference Include="$(MsbuildThisFileDirectory)..\..\WixToolset.Dnc.HostGenerator\WixToolset.Dnc.HostGenerator.csproj"
12 OutputItemType="Analyzer"
13 ReferenceOutputAssembly="false" />
14 </ItemGroup>
15
16 <ItemGroup>
17 <PackageReference Include="WixToolset.Mba.Core" />
18 </ItemGroup>
19</Project>
diff --git a/src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj b/src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj
index 8069df45..9b9f2bf6 100644
--- a/src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj
+++ b/src/ext/Bal/test/examples/EarliestCoreMBA/Example.EarliestCoreMBA.csproj
@@ -3,15 +3,7 @@
3 <PropertyGroup> 3 <PropertyGroup>
4 <TargetFramework>netcoreapp3.1</TargetFramework> 4 <TargetFramework>netcoreapp3.1</TargetFramework>
5 <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers> 5 <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
6 <EnableDynamicLoading>true</EnableDynamicLoading> 6 <IsDncBA>true</IsDncBA>
7 <Description>Earliest .NET Core MBA</Description> 7 <Description>Earliest .NET Core MBA</Description>
8 </PropertyGroup> 8 </PropertyGroup>
9
10 <ItemGroup>
11 <TrimmerRootAssembly Include="System.Runtime.Loader" />
12 </ItemGroup>
13
14 <ItemGroup>
15 <PackageReference Include="WixToolset.Mba.Core" />
16 </ItemGroup>
17</Project> 9</Project>
diff --git a/src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj b/src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj
index aad56a3e..a884fa07 100644
--- a/src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj
+++ b/src/ext/Bal/test/examples/LatestCoreMBA/Example.LatestCoreMBA.csproj
@@ -3,18 +3,7 @@
3 <PropertyGroup> 3 <PropertyGroup>
4 <TargetFramework>net5.0</TargetFramework> 4 <TargetFramework>net5.0</TargetFramework>
5 <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers> 5 <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
6 <EnableDynamicLoading>true</EnableDynamicLoading> 6 <IsDncBA>true</IsDncBA>
7 <Description>Latest .NET Core MBA</Description> 7 <Description>Latest .NET Core MBA</Description>
8 </PropertyGroup> 8 </PropertyGroup>
9
10 <ItemGroup>
11 <TrimmerRootAssembly Include="System.Diagnostics.Tools" />
12 <TrimmerRootAssembly Include="System.Runtime" />
13 <TrimmerRootAssembly Include="System.Runtime.InteropServices" />
14 <TrimmerRootAssembly Include="System.Runtime.Loader" />
15 </ItemGroup>
16
17 <ItemGroup>
18 <PackageReference Include="WixToolset.Mba.Core" />
19 </ItemGroup>
20</Project> 9</Project>
diff --git a/src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj b/src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj
index 3d63e7b9..3186148b 100644
--- a/src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj
+++ b/src/ext/Bal/test/examples/WPFCoreMBA/Example.WPFCoreMBA.csproj
@@ -3,22 +3,8 @@
3 <PropertyGroup> 3 <PropertyGroup>
4 <TargetFramework>net5.0-windows</TargetFramework> 4 <TargetFramework>net5.0-windows</TargetFramework>
5 <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers> 5 <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
6 <EnableDynamicLoading>true</EnableDynamicLoading> 6 <IsDncBA>true</IsDncBA>
7 <Description>WPF .NET Core MBA</Description> 7 <Description>WPF .NET Core MBA</Description>
8 <UseWPF>true</UseWPF> 8 <UseWPF>true</UseWPF>
9 </PropertyGroup> 9 </PropertyGroup>
10
11 <ItemGroup>
12 <PackageReference Include="WixToolset.Mba.Core" />
13 </ItemGroup>
14
15 <Target Name="GitVersion">
16 <PropertyGroup>
17 <GitBaseVersionMajor>42</GitBaseVersionMajor>
18 <GitBaseVersionMinor>42</GitBaseVersionMinor>
19 <GitBaseVersionPatch>42</GitBaseVersionPatch>
20 <GitCommits>42</GitCommits>
21 <GitSha>abc123def456</GitSha>
22 </PropertyGroup>
23 </Target>
24</Project> 10</Project>
diff --git a/src/ext/Bal/test/examples/examples.proj b/src/ext/Bal/test/examples/examples.proj
index 5722cfcb..a16af2a4 100644
--- a/src/ext/Bal/test/examples/examples.proj
+++ b/src/ext/Bal/test/examples/examples.proj
@@ -17,14 +17,15 @@
17 <ItemGroup> 17 <ItemGroup>
18 <CoreMBAProject Include="$(EarliestCoreMBAProjectPath)"> 18 <CoreMBAProject Include="$(EarliestCoreMBAProjectPath)">
19 <PublishPath>$(MBAPublishPath)Example.EarliestCoreMBA</PublishPath> 19 <PublishPath>$(MBAPublishPath)Example.EarliestCoreMBA</PublishPath>
20 <TrimMode>CopyUsed</TrimMode>
20 </CoreMBAProject> 21 </CoreMBAProject>
21 <CoreMBAProject Include="$(LatestCoreMBAProjectPath)"> 22 <CoreMBAProject Include="$(LatestCoreMBAProjectPath)">
22 <PublishPath>$(MBAPublishPath)Example.LatestCoreMBA</PublishPath> 23 <PublishPath>$(MBAPublishPath)Example.LatestCoreMBA</PublishPath>
24 <TrimMode>Link</TrimMode>
23 </CoreMBAProject> 25 </CoreMBAProject>
24 <CoreMBAProject Include="$(WPFCoreMBAProjectPath)"> 26 <CoreMBAProject Include="$(WPFCoreMBAProjectPath)">
25 <PublishPath>$(MBAPublishPath)Example.WPFCoreMBA</PublishPath> 27 <PublishPath>$(MBAPublishPath)Example.WPFCoreMBA</PublishPath>
26 <SkipSCD>true</SkipSCD> 28 <SkipSCD>true</SkipSCD>
27 <SkipTrimmedSCD>true</SkipTrimmedSCD>
28 </CoreMBAProject> 29 </CoreMBAProject>
29 30
30 <FullMBAProject Include="$(FullFramework2MBAProjectPath)" /> 31 <FullMBAProject Include="$(FullFramework2MBAProjectPath)" />
@@ -38,8 +39,8 @@
38 Condition="'%(CoreMBAProject.SkipFDD)'==''" /> 39 Condition="'%(CoreMBAProject.SkipFDD)'==''" />
39 <Exec Command='dotnet publish -o "%(CoreMBAProject.PublishPath)\scd" -r win-x86 -c $(Configuration) --self-contained true "%(CoreMBAProject.Identity)"' 40 <Exec Command='dotnet publish -o "%(CoreMBAProject.PublishPath)\scd" -r win-x86 -c $(Configuration) --self-contained true "%(CoreMBAProject.Identity)"'
40 Condition="'%(CoreMBAProject.SkipSCD)'==''" /> 41 Condition="'%(CoreMBAProject.SkipSCD)'==''" />
41 <Exec Command='dotnet publish -o "%(CoreMBAProject.PublishPath)\trimmedscd" -r win-x86 -c $(Configuration) --self-contained true -p:PublishTrimmed=true "%(CoreMBAProject.Identity)"' 42 <Exec Command='dotnet publish -o "%(CoreMBAProject.PublishPath)\trimmedscd" -r win-x86 -c $(Configuration) --self-contained true -p:PublishTrimmed=true -p:TrimMode=%(CoreMBAProject.TrimMode) "%(CoreMBAProject.Identity)"'
42 Condition="'%(CoreMBAProject.SkipTrimmedSCD)'==''" /> 43 Condition="'%(CoreMBAProject.TrimMode)'!=''" />
43 </Target> 44 </Target>
44 45
45 <Target Name="Build" DependsOnTargets="PublishCoreExamples"> 46 <Target Name="Build" DependsOnTargets="PublishCoreExamples">