Skip to content

Commit e6bfef3

Browse files
committed
Run under 32bit .NET Core as needed
1 parent 823da3d commit e6bfef3

File tree

15 files changed

+309
-39
lines changed

15 files changed

+309
-39
lines changed

NUnitConsole.sln

+18
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ EndProject
110110
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cake", "cake", "{9BCA00E2-D072-424B-A6DF-5BECF719C1FB}"
111111
ProjectSection(SolutionItems) = preProject
112112
cake\constants.cake = cake\constants.cake
113+
cake\dotnet.cake = cake\dotnet.cake
113114
cake\header-check.cake = cake\header-check.cake
114115
cake\package-checks.cake = cake\package-checks.cake
115116
cake\package-definitions.cake = cake\package-definitions.cake
@@ -122,6 +123,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cake", "cake", "{9BCA00E2-D
122123
EndProject
123124
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "msi", "msi", "{0C0D20CE-70CD-4CEF-BE9B-AEB8A2DE9C8A}"
124125
ProjectSection(SolutionItems) = preProject
126+
msi\nunit-install.sln = msi\nunit-install.sln
125127
msi\resources\nunit.bundle.addins = msi\resources\nunit.bundle.addins
126128
EndProjectSection
127129
EndProject
@@ -151,6 +153,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{C5B712
151153
.config\dotnet-tools.json = .config\dotnet-tools.json
152154
EndProjectSection
153155
EndProject
156+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nunit", "nunit", "{93E5CAF4-D5DB-4915-AF0F-908A6043E462}"
157+
ProjectSection(SolutionItems) = preProject
158+
msi\nunit\addin-files.wxi = msi\nunit\addin-files.wxi
159+
msi\nunit\banner.bmp = msi\nunit\banner.bmp
160+
msi\nunit\console-files.wxi = msi\nunit\console-files.wxi
161+
msi\nunit\dialog.bmp = msi\nunit\dialog.bmp
162+
msi\nunit\engine-files.wxi = msi\nunit\engine-files.wxi
163+
msi\nunit\nunit.wixproj = msi\nunit\nunit.wixproj
164+
msi\nunit\nunit.wxs = msi\nunit\nunit.wxs
165+
msi\nunit\runner-directories.wxi = msi\nunit\runner-directories.wxi
166+
msi\nunit\runner-features.wxi = msi\nunit\runner-features.wxi
167+
msi\nunit\utility-files.wxi = msi\nunit\utility-files.wxi
168+
msi\nunit\variables.wxi = msi\nunit\variables.wxi
169+
EndProjectSection
170+
EndProject
154171
Global
155172
GlobalSection(SolutionConfigurationPlatforms) = preSolution
156173
Debug|Any CPU = Debug|Any CPU
@@ -235,6 +252,7 @@ Global
235252
{08F8160E-E691-4F07-9F57-EA31B9736429} = {25DA12FE-6209-4524-9A37-8E51F815E198}
236253
{50371E48-BEC3-4D53-BD37-F3A6149CFD0D} = {25DA12FE-6209-4524-9A37-8E51F815E198}
237254
{C5B7120C-190B-4C38-95CB-83F12799598D} = {49D441DF-39FD-4F4D-AECA-86CF8EFE23AF}
255+
{93E5CAF4-D5DB-4915-AF0F-908A6043E462} = {0C0D20CE-70CD-4CEF-BE9B-AEB8A2DE9C8A}
238256
EndGlobalSection
239257
GlobalSection(ExtensibilityGlobals) = postSolution
240258
SolutionGuid = {D8E4FC26-5422-4C51-8BBC-D1AC0A578711}

build.cake

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ static string Configuration; Configuration = GetArgument("configuration|c", "Rel
33
static bool NoPush; NoPush = HasArgument("nopush");
44

55
#load cake/constants.cake
6+
#load cake/dotnet.cake
67
#load cake/header-check.cake
78
#load cake/package-checks.cake
89
#load cake/test-results.cake

cake/dotnet.cake

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
public class DotnetInfo
2+
{
3+
// Experimenting with finding dotnet installs for X64 vs x86
4+
// This code will end up moved into the engine as well.
5+
6+
private ICakeContext _context;
7+
private bool _onWindows;
8+
9+
public DotnetInfo(ICakeContext context)
10+
{
11+
_context = context;
12+
_onWindows = context.IsRunningOnWindows();
13+
14+
InstallPath = GetDotnetInstallDirectory(false);
15+
X86InstallPath = GetDotnetInstallDirectory(true);
16+
}
17+
18+
// NOTES:
19+
// * We don't need an IsInstalled property because our scripts all run under dotnet.
20+
21+
public bool IsX86Installed => System.IO.Directory.Exists(X86InstallPath) && System.IO.File.Exists(X86Executable);
22+
23+
public string InstallPath { get; }
24+
public string Executable => InstallPath + "dotnet.exe";
25+
public List<string> Runtimes { get; }
26+
27+
public string X86InstallPath { get; }
28+
public string X86Executable => X86InstallPath + "dotnet.exe";
29+
public List<string> X86Runtimes { get; }
30+
31+
public void Display()
32+
{
33+
_context.Information($"Install Path: {InstallPath}");
34+
_context.Information($"Executable: {Executable}");
35+
_context.Information("Runtimes:");
36+
foreach (string dir in System.IO.Directory.GetDirectories(System.IO.Path.Combine(InstallPath, "shared")))
37+
{
38+
string runtime = System.IO.Path.GetFileName(dir);
39+
foreach (string dir2 in System.IO.Directory.GetDirectories(dir))
40+
{
41+
string version = System.IO.Path.GetFileName(dir2);
42+
_context.Information($" {runtime} {version}");
43+
}
44+
}
45+
46+
if (IsX86Installed)
47+
{
48+
_context.Information($"\nX86 Install Path: {X86InstallPath}");
49+
_context.Information($"X86 Executable: {X86Executable}");
50+
_context.Information("Runtimes:");
51+
foreach (var dir in System.IO.Directory.GetDirectories(System.IO.Path.Combine(X86InstallPath, "shared")))
52+
{
53+
string runtime = System.IO.Path.GetFileName(dir);
54+
foreach (string dir2 in System.IO.Directory.GetDirectories(dir))
55+
{
56+
string version = System.IO.Path.GetFileName(dir2);
57+
_context.Information($" {runtime} {version}");
58+
}
59+
}
60+
}
61+
else
62+
_context.Information("\nDotnet X86 is not installed");
63+
}
64+
65+
private string GetDotnetInstallDirectory(bool forX86 = false)
66+
{
67+
if (_onWindows)
68+
{
69+
if (forX86)
70+
{
71+
Microsoft.Win32.RegistryKey key =
72+
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\dotnet\SetUp\InstalledVersions\x86\");
73+
return (string)key?.GetValue("InstallLocation");
74+
}
75+
else
76+
{
77+
Microsoft.Win32.RegistryKey key =
78+
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\dotnet\SetUp\InstalledVersions\x64\sharedHost\");
79+
return (string)key?.GetValue("Path");
80+
}
81+
}
82+
else // Assuming linux for now
83+
return "/usr/shared/dotnet/";
84+
}
85+
}
86+
87+
// Use this task to verify that the script understands the dotnet environment
88+
Task("DotnetInfo").Does(() => { new DotnetInfo(Context).Display(); });

cake/package-definitions.cake

+20
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public void InitializePackageDefinitions(ICakeContext context)
2828
NetCore31Test,
2929
Net50Test,
3030
Net60Test,
31+
Net70Test,
32+
Net80Test,
3133
Net50PlusNet60Test,
3234
Net40PlusNet60Test
3335
};
@@ -42,6 +44,24 @@ public void InitializePackageDefinitions(ICakeContext context)
4244
Net80Test,
4345
};
4446

47+
// TODO: Remove the limitation to Windows
48+
if (IsRunningOnWindows() && dotnetX86Available)
49+
{
50+
StandardRunnerTests.Add(Net60X86Test);
51+
// TODO: Make these tests run on AppVeyor
52+
if (!context.BuildSystem().IsRunningOnAppVeyor)
53+
{
54+
StandardRunnerTests.Add(NetCore31X86Test);
55+
StandardRunnerTests.Add(Net50X86Test);
56+
StandardRunnerTests.Add(Net70X86Test);
57+
StandardRunnerTests.Add(Net80X86Test);
58+
}
59+
// Currently, NetCoreRunner runs tests in process. As a result,
60+
// X86 tests will work in our environment, although uses may run
61+
// it as a tool using the X86 architecture.
62+
}
63+
64+
4565
AllPackages.AddRange(new PackageDefinition[] {
4666

4767
NUnitConsoleNuGetPackage = new NuGetPackage(

cake/package-tests.cake

+30
Original file line numberDiff line numberDiff line change
@@ -48,30 +48,60 @@ static PackageTest Net80Test = new PackageTest(
4848
"net8.0/mock-assembly.dll",
4949
MockAssemblyExpectedResult(1));
5050

51+
static PackageTest Net80X86Test = new PackageTest(
52+
"Net80X86Test",
53+
"Run mock-assembly-x86.dll under .NET 8.0",
54+
"net8.0/mock-assembly-x86.dll",
55+
MockAssemblyExpectedResult(1));
56+
5157
static PackageTest Net70Test = new PackageTest(
5258
"Net70Test",
5359
"Run mock-assembly.dll under .NET 7.0",
5460
"net7.0/mock-assembly.dll",
5561
MockAssemblyExpectedResult(1));
5662

63+
static PackageTest Net70X86Test = new PackageTest(
64+
"Net70X86Test",
65+
"Run mock-assembly-x86.dll under .NET 7.0",
66+
"net7.0/mock-assembly-x86.dll",
67+
MockAssemblyExpectedResult(1));
68+
5769
static PackageTest Net60Test = new PackageTest(
5870
"Net60Test",
5971
"Run mock-assembly.dll under .NET 6.0",
6072
"net6.0/mock-assembly.dll",
6173
MockAssemblyExpectedResult(1));
6274

75+
static PackageTest Net60X86Test = new PackageTest(
76+
"Net60X86Test",
77+
"Run mock-assembly-x86.dll under .NET 6.0",
78+
"net6.0/mock-assembly-x86.dll --trace:Debug",
79+
MockAssemblyExpectedResult(1));
80+
6381
static PackageTest Net50Test = new PackageTest(
6482
"Net50Test",
6583
"Run mock-assembly.dll under .NET 5.0",
6684
"net5.0/mock-assembly.dll",
6785
MockAssemblyExpectedResult(1));
6886

87+
static PackageTest Net50X86Test = new PackageTest(
88+
"Net50X86Test",
89+
"Run mock-assembly-x86.dll under .NET 5.0",
90+
"net5.0/mock-assembly-x86.dll",
91+
MockAssemblyExpectedResult(1));
92+
6993
static PackageTest NetCore31Test = new PackageTest(
7094
"NetCore31Test",
7195
"Run mock-assembly.dll under .NET Core 3.1",
7296
"netcoreapp3.1/mock-assembly.dll",
7397
MockAssemblyExpectedResult(1));
7498

99+
static PackageTest NetCore31X86Test = new PackageTest(
100+
"NetCore31X86Test",
101+
"Run mock-assembly-x86.dll under .NET Core 3.1",
102+
"netcoreapp3.1/mock-assembly-x86.dll",
103+
MockAssemblyExpectedResult(1));
104+
75105
static PackageTest Net50PlusNet60Test = new PackageTest(
76106
"Net50PlusNet60Test",
77107
"Run mock-assembly under .NET 5.0 and 6.0 together",

msi/nunit/engine-files.wxi

+77-5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
<ComponentGroupRef Id="NETCORE31_AGENT" />
5050
<ComponentGroupRef Id="NET50_AGENT" />
5151
<ComponentGroupRef Id="NET60_AGENT" />
52+
<ComponentGroupRef Id="NET70_AGENT" />
53+
<ComponentGroupRef Id="NET80_AGENT" />
5254
</ComponentGroup>
5355
</Fragment>
5456
<Fragment>
@@ -175,24 +177,94 @@
175177
<Component Id="NUNIT_AGENT_NET60_ENGINE_API" Location="local" Guid="393F8699-4F44-479B-916D-34F506F089D1">
176178
<File Id="nunit.agent.net60.engine.api.dll"
177179
ProcessorArchitecture="msil"
178-
Source="$(var.InstallImage)bin/net6.0/nunit.engine.api.dll" />
180+
Source="$(var.InstallImage)bin/agents/net6.0/nunit.engine.api.dll" />
179181
<File Id="nunit.agent.net60.engine.api.xml"
180-
Source="$(var.InstallImage)bin/net6.0/nunit.engine.api.xml" />
182+
Source="$(var.InstallImage)bin/agents/net6.0/nunit.engine.api.xml" />
181183
</Component>
182184
<Component Id="NUNIT_AGENT_NET60_ENGINE_CORE" Location="local" Guid="583A7D7E-9046-408C-8AA1-821EFCC2A7EA">
183185
<File Id="nunit.agent.net60.engine.core.dll"
184186
ProcessorArchitecture="msil"
185-
Source="$(var.InstallImage)bin/net6.0/nunit.engine.core.dll" />
187+
Source="$(var.InstallImage)bin/agents/net6.0/nunit.engine.core.dll" />
186188
</Component>
187189
<Component Id="NUNIT_AGENT_NET60_ENGINE_METADATA" Location="local" Guid="8F00367C-4FFD-429D-8483-D5FA6D109627">
188190
<File Id="nunit.agent.net60.engine.metadata.dll"
189191
ProcessorArchitecture="msil"
190-
Source="$(var.InstallImage)bin/net6.0/testcentric.engine.metadata.dll" />
192+
Source="$(var.InstallImage)bin/agents/net6.0/testcentric.engine.metadata.dll" />
191193
</Component>
192194
<Component Id="NUNIT_AGENT_NET60_DEPENDENCY_MODEL" Location="local" Guid="EFD82EAE-A38E-45E0-944B-A776F7353100">
193195
<File Id="Microsoft.Extensions.DependencyModel.net60.dll"
194196
ProcessorArchitecture="msil"
195-
Source="$(var.InstallImage)bin/net6.0/Microsoft.Extensions.DependencyModel.dll" />
197+
Source="$(var.InstallImage)bin/agents/net6.0/Microsoft.Extensions.DependencyModel.dll" />
198+
</Component>
199+
</ComponentGroup>
200+
<ComponentGroup Id="NET70_AGENT" Directory="NET70_AGENT_DIR">
201+
<Component Id="NUNIT_AGENT_NET70" Location="local" Guid="F1B28B46-EBAE-4D3D-AFAB-9E60B0F35EDC">
202+
<File Id="nunit_agent_net70.dll"
203+
ProcessorArchitecture="msil"
204+
Source="$(var.InstallImage)bin/agents/net7.0/nunit-agent.dll" />
205+
<File Id="nunit_agent_net70.dll.config"
206+
Source="$(var.InstallImage)bin/agents/net7.0/nunit-agent.dll.config" />
207+
<File Id="nunit_agent_net70.deps.json"
208+
Source="$(var.InstallImage)bin/agents/net7.0/nunit-agent.deps.json" />
209+
<File Id="nunit_agent_net70.runtimeconfig.json"
210+
Source="$(var.InstallImage)bin/agents/net7.0/nunit-agent.runtimeconfig.json" />
211+
</Component>
212+
<Component Id="NUNIT_AGENT_NET70_ENGINE_API" Location="local" Guid="03667196-96FA-4AE9-8A1B-6059FA520CD9">
213+
<File Id="nunit.agent.net70.engine.api.dll"
214+
ProcessorArchitecture="msil"
215+
Source="$(var.InstallImage)bin/agents/net7.0/nunit.engine.api.dll" />
216+
<File Id="nunit.agent.net70.engine.api.xml"
217+
Source="$(var.InstallImage)bin/agents/net7.0/nunit.engine.api.xml" />
218+
</Component>
219+
<Component Id="NUNIT_AGENT_NET70_ENGINE_CORE" Location="local" Guid="1CA60508-6E99-4FD5-AE90-023EC61C2CDB">
220+
<File Id="nunit.agent.net70.engine.core.dll"
221+
ProcessorArchitecture="msil"
222+
Source="$(var.InstallImage)bin/agents/net7.0/nunit.engine.core.dll" />
223+
</Component>
224+
<Component Id="NUNIT_AGENT_NET70_ENGINE_METADATA" Location="local" Guid="B2BEE75C-2BCA-4D81-BA23-64F309A5B45D">
225+
<File Id="nunit.agent.net70.engine.metadata.dll"
226+
ProcessorArchitecture="msil"
227+
Source="$(var.InstallImage)bin/agents/net7.0/testcentric.engine.metadata.dll" />
228+
</Component>
229+
<Component Id="NUNIT_AGENT_NET70_DEPENDENCY_MODEL" Location="local" Guid="B6C3D2CF-8441-4479-8EDE-A4E76A487F63">
230+
<File Id="Microsoft.Extensions.DependencyModel.net70.dll"
231+
ProcessorArchitecture="msil"
232+
Source="$(var.InstallImage)bin/agents/net7.0/Microsoft.Extensions.DependencyModel.dll" />
233+
</Component>
234+
</ComponentGroup>
235+
<ComponentGroup Id="NET80_AGENT" Directory="NET80_AGENT_DIR">
236+
<Component Id="NUNIT_AGENT_NET80" Location="local" Guid="D8F8C2FB-E60E-455E-9C6A-B715268F3260">
237+
<File Id="nunit_agent_net80.dll"
238+
ProcessorArchitecture="msil"
239+
Source="$(var.InstallImage)bin/agents/net8.0/nunit-agent.dll" />
240+
<File Id="nunit_agent_net80.dll.config"
241+
Source="$(var.InstallImage)bin/agents/net8.0/nunit-agent.dll.config" />
242+
<File Id="nunit_agent_net80.deps.json"
243+
Source="$(var.InstallImage)bin/agents/net8.0/nunit-agent.deps.json" />
244+
<File Id="nunit_agent_net80.runtimeconfig.json"
245+
Source="$(var.InstallImage)bin/agents/net8.0/nunit-agent.runtimeconfig.json" />
246+
</Component>
247+
<Component Id="NUNIT_AGENT_NET80_ENGINE_API" Location="local" Guid="74172ECE-BEE7-4961-9A6A-DA0D06120C88">
248+
<File Id="nunit.agent.net80.engine.api.dll"
249+
ProcessorArchitecture="msil"
250+
Source="$(var.InstallImage)bin/agents/net8.0/nunit.engine.api.dll" />
251+
<File Id="nunit.agent.net80.engine.api.xml"
252+
Source="$(var.InstallImage)bin/net8.0/nunit.engine.api.xml" />
253+
</Component>
254+
<Component Id="NUNIT_AGENT_NET80_ENGINE_CORE" Location="local" Guid="A24E77FD-350C-4E6C-B467-A7877CF9D656">
255+
<File Id="nunit.agent.net80.engine.core.dll"
256+
ProcessorArchitecture="msil"
257+
Source="$(var.InstallImage)bin/agents/net8.0/nunit.engine.core.dll" />
258+
</Component>
259+
<Component Id="NUNIT_AGENT_NET80_ENGINE_METADATA" Location="local" Guid="CFE58B66-97D3-434D-A929-638D07F23D94">
260+
<File Id="nunit.agent.net80.engine.metadata.dll"
261+
ProcessorArchitecture="msil"
262+
Source="$(var.InstallImage)bin/agents/net8.0/testcentric.engine.metadata.dll" />
263+
</Component>
264+
<Component Id="NUNIT_AGENT_NET80_DEPENDENCY_MODEL" Location="local" Guid="F3B15759-D568-430E-84A2-773CB9E9BBBA">
265+
<File Id="Microsoft.Extensions.DependencyModel.net80.dll"
266+
ProcessorArchitecture="msil"
267+
Source="$(var.InstallImage)bin/agents/net8.0/Microsoft.Extensions.DependencyModel.dll" />
196268
</Component>
197269
</ComponentGroup>
198270
</Fragment>

msi/nunit/runner-directories.wxi

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<Directory Id="NETCORE31_AGENT_DIR" Name="netcoreapp3.1" />
1717
<Directory Id="NET50_AGENT_DIR" Name="net5.0" />
1818
<Directory Id="NET60_AGENT_DIR" Name="net6.0" />
19+
<Directory Id="NET70_AGENT_DIR" Name="net7.0" />
20+
<Directory Id="NET80_AGENT_DIR" Name="net8.0" />
1921
</Directory>
2022
</Directory>
2123
</DirectoryRef>

src/NUnitEngine/mock-assembly-x86/mock-assembly-x86.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<RootNamespace>NUnit.Tests</RootNamespace>
5-
<TargetFrameworks>net35;net40;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
5+
<TargetFrameworks>net35;net40;netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
66
<SignAssembly>true</SignAssembly>
77
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
88
<PlatformTarget>x86</PlatformTarget>

src/NUnitEngine/nunit.engine.api/IRuntimeFrameworkService.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ public interface IRuntimeFrameworkService
1616
/// the string passed as an argument is available.
1717
/// </summary>
1818
/// <param name="framework">A string representing a framework, like 'net-4.0'</param>
19+
/// <param name="x86">A flag indicating whether the X86 architecture is needed. Defaults to false.</param>
1920
/// <returns>True if the framework is available, false if unavailable or nonexistent</returns>
20-
bool IsAvailable(string framework);
21+
bool IsAvailable(string framework, bool x86);
2122

2223
/// <summary>
2324
/// Selects a target runtime framework for a TestPackage based on

0 commit comments

Comments
 (0)