Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1369 #1413

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-metadata-padding: 5
commits-since-version-source-padding: 5
branches:
master:
regex: ^(main|version3X)$
regex: ^(main|version4)$
tag: dev
release:
tag: pre
Expand Down
18 changes: 18 additions & 0 deletions NUnitConsole.sln
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cake", "cake", "{9BCA00E2-D072-424B-A6DF-5BECF719C1FB}"
ProjectSection(SolutionItems) = preProject
cake\constants.cake = cake\constants.cake
cake\dotnet.cake = cake\dotnet.cake
cake\header-check.cake = cake\header-check.cake
cake\package-checks.cake = cake\package-checks.cake
cake\package-definitions.cake = cake\package-definitions.cake
Expand All @@ -122,6 +123,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cake", "cake", "{9BCA00E2-D
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "msi", "msi", "{0C0D20CE-70CD-4CEF-BE9B-AEB8A2DE9C8A}"
ProjectSection(SolutionItems) = preProject
msi\nunit-install.sln = msi\nunit-install.sln
msi\resources\nunit.bundle.addins = msi\resources\nunit.bundle.addins
EndProjectSection
EndProject
Expand Down Expand Up @@ -151,6 +153,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{C5B712
.config\dotnet-tools.json = .config\dotnet-tools.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nunit", "nunit", "{93E5CAF4-D5DB-4915-AF0F-908A6043E462}"
ProjectSection(SolutionItems) = preProject
msi\nunit\addin-files.wxi = msi\nunit\addin-files.wxi
msi\nunit\banner.bmp = msi\nunit\banner.bmp
msi\nunit\console-files.wxi = msi\nunit\console-files.wxi
msi\nunit\dialog.bmp = msi\nunit\dialog.bmp
msi\nunit\engine-files.wxi = msi\nunit\engine-files.wxi
msi\nunit\nunit.wixproj = msi\nunit\nunit.wixproj
msi\nunit\nunit.wxs = msi\nunit\nunit.wxs
msi\nunit\runner-directories.wxi = msi\nunit\runner-directories.wxi
msi\nunit\runner-features.wxi = msi\nunit\runner-features.wxi
msi\nunit\utility-files.wxi = msi\nunit\utility-files.wxi
msi\nunit\variables.wxi = msi\nunit\variables.wxi
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -235,6 +252,7 @@ Global
{08F8160E-E691-4F07-9F57-EA31B9736429} = {25DA12FE-6209-4524-9A37-8E51F815E198}
{50371E48-BEC3-4D53-BD37-F3A6149CFD0D} = {25DA12FE-6209-4524-9A37-8E51F815E198}
{C5B7120C-190B-4C38-95CB-83F12799598D} = {49D441DF-39FD-4F4D-AECA-86CF8EFE23AF}
{93E5CAF4-D5DB-4915-AF0F-908A6043E462} = {0C0D20CE-70CD-4CEF-BE9B-AEB8A2DE9C8A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D8E4FC26-5422-4C51-8BBC-D1AC0A578711}
Expand Down
1 change: 1 addition & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ static string Configuration; Configuration = GetArgument("configuration|c", "Rel
static bool NoPush; NoPush = HasArgument("nopush");

#load cake/constants.cake
#load cake/dotnet.cake
#load cake/header-check.cake
#load cake/package-checks.cake
#load cake/test-results.cake
Expand Down
88 changes: 88 additions & 0 deletions cake/dotnet.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
public class DotnetInfo
{
// Experimenting with finding dotnet installs for X64 vs x86
// This code will end up moved into the engine as well.

private ICakeContext _context;
private bool _onWindows;

public DotnetInfo(ICakeContext context)
{
_context = context;
_onWindows = context.IsRunningOnWindows();

InstallPath = GetDotnetInstallDirectory(false);
X86InstallPath = GetDotnetInstallDirectory(true);
}

// NOTES:
// * We don't need an IsInstalled property because our scripts all run under dotnet.

public bool IsX86Installed => System.IO.Directory.Exists(X86InstallPath) && System.IO.File.Exists(X86Executable);

public string InstallPath { get; }
public string Executable => InstallPath + "dotnet.exe";
public List<string> Runtimes { get; }

public string X86InstallPath { get; }
public string X86Executable => X86InstallPath + "dotnet.exe";
public List<string> X86Runtimes { get; }

public void Display()
{
_context.Information($"Install Path: {InstallPath}");
_context.Information($"Executable: {Executable}");
_context.Information("Runtimes:");
foreach (string dir in System.IO.Directory.GetDirectories(System.IO.Path.Combine(InstallPath, "shared")))
{
string runtime = System.IO.Path.GetFileName(dir);
foreach (string dir2 in System.IO.Directory.GetDirectories(dir))
{
string version = System.IO.Path.GetFileName(dir2);
_context.Information($" {runtime} {version}");
}
}

if (IsX86Installed)
{
_context.Information($"\nX86 Install Path: {X86InstallPath}");
_context.Information($"X86 Executable: {X86Executable}");
_context.Information("Runtimes:");
foreach (var dir in System.IO.Directory.GetDirectories(System.IO.Path.Combine(X86InstallPath, "shared")))
{
string runtime = System.IO.Path.GetFileName(dir);
foreach (string dir2 in System.IO.Directory.GetDirectories(dir))
{
string version = System.IO.Path.GetFileName(dir2);
_context.Information($" {runtime} {version}");
}
}
}
else
_context.Information("\nDotnet X86 is not installed");
}

private string GetDotnetInstallDirectory(bool forX86 = false)
{
if (_onWindows)
{
if (forX86)
{
Microsoft.Win32.RegistryKey key =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\dotnet\SetUp\InstalledVersions\x86\");
return (string)key?.GetValue("InstallLocation");
}
else
{
Microsoft.Win32.RegistryKey key =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\dotnet\SetUp\InstalledVersions\x64\sharedHost\");
return (string)key?.GetValue("Path");
}
}
else // Assuming linux for now
return "/usr/shared/dotnet/";
}
}

// Use this task to verify that the script understands the dotnet environment
Task("DotnetInfo").Does(() => { new DotnetInfo(Context).Display(); });
20 changes: 20 additions & 0 deletions cake/package-definitions.cake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public void InitializePackageDefinitions(ICakeContext context)
NetCore31Test,
Net50Test,
Net60Test,
Net70Test,
Net80Test,
Net50PlusNet60Test,
Net40PlusNet60Test
};
Expand All @@ -42,6 +44,24 @@ public void InitializePackageDefinitions(ICakeContext context)
Net80Test,
};

// TODO: Remove the limitation to Windows
if (IsRunningOnWindows() && dotnetX86Available)
{
StandardRunnerTests.Add(Net60X86Test);
// TODO: Make these tests run on AppVeyor
if (!context.BuildSystem().IsRunningOnAppVeyor)
{
StandardRunnerTests.Add(NetCore31X86Test);
StandardRunnerTests.Add(Net50X86Test);
StandardRunnerTests.Add(Net70X86Test);
StandardRunnerTests.Add(Net80X86Test);
}
// Currently, NetCoreRunner runs tests in process. As a result,
// X86 tests will work in our environment, although uses may run
// it as a tool using the X86 architecture.
}


AllPackages.AddRange(new PackageDefinition[] {

NUnitConsoleNuGetPackage = new NuGetPackage(
Expand Down
30 changes: 30 additions & 0 deletions cake/package-tests.cake
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,60 @@ static PackageTest Net80Test = new PackageTest(
"net8.0/mock-assembly.dll",
MockAssemblyExpectedResult(1));

static PackageTest Net80X86Test = new PackageTest(
"Net80X86Test",
"Run mock-assembly-x86.dll under .NET 8.0",
"net8.0/mock-assembly-x86.dll",
MockAssemblyExpectedResult(1));

static PackageTest Net70Test = new PackageTest(
"Net70Test",
"Run mock-assembly.dll under .NET 7.0",
"net7.0/mock-assembly.dll",
MockAssemblyExpectedResult(1));

static PackageTest Net70X86Test = new PackageTest(
"Net70X86Test",
"Run mock-assembly-x86.dll under .NET 7.0",
"net7.0/mock-assembly-x86.dll",
MockAssemblyExpectedResult(1));

static PackageTest Net60Test = new PackageTest(
"Net60Test",
"Run mock-assembly.dll under .NET 6.0",
"net6.0/mock-assembly.dll",
MockAssemblyExpectedResult(1));

static PackageTest Net60X86Test = new PackageTest(
"Net60X86Test",
"Run mock-assembly-x86.dll under .NET 6.0",
"net6.0/mock-assembly-x86.dll --trace:Debug",
MockAssemblyExpectedResult(1));

static PackageTest Net50Test = new PackageTest(
"Net50Test",
"Run mock-assembly.dll under .NET 5.0",
"net5.0/mock-assembly.dll",
MockAssemblyExpectedResult(1));

static PackageTest Net50X86Test = new PackageTest(
"Net50X86Test",
"Run mock-assembly-x86.dll under .NET 5.0",
"net5.0/mock-assembly-x86.dll",
MockAssemblyExpectedResult(1));

static PackageTest NetCore31Test = new PackageTest(
"NetCore31Test",
"Run mock-assembly.dll under .NET Core 3.1",
"netcoreapp3.1/mock-assembly.dll",
MockAssemblyExpectedResult(1));

static PackageTest NetCore31X86Test = new PackageTest(
"NetCore31X86Test",
"Run mock-assembly-x86.dll under .NET Core 3.1",
"netcoreapp3.1/mock-assembly-x86.dll",
MockAssemblyExpectedResult(1));

static PackageTest Net50PlusNet60Test = new PackageTest(
"Net50PlusNet60Test",
"Run mock-assembly under .NET 5.0 and 6.0 together",
Expand Down
82 changes: 77 additions & 5 deletions msi/nunit/engine-files.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<ComponentGroupRef Id="NETCORE31_AGENT" />
<ComponentGroupRef Id="NET50_AGENT" />
<ComponentGroupRef Id="NET60_AGENT" />
<ComponentGroupRef Id="NET70_AGENT" />
<ComponentGroupRef Id="NET80_AGENT" />
</ComponentGroup>
</Fragment>
<Fragment>
Expand Down Expand Up @@ -175,24 +177,94 @@
<Component Id="NUNIT_AGENT_NET60_ENGINE_API" Location="local" Guid="393F8699-4F44-479B-916D-34F506F089D1">
<File Id="nunit.agent.net60.engine.api.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/net6.0/nunit.engine.api.dll" />
Source="$(var.InstallImage)bin/agents/net6.0/nunit.engine.api.dll" />
<File Id="nunit.agent.net60.engine.api.xml"
Source="$(var.InstallImage)bin/net6.0/nunit.engine.api.xml" />
Source="$(var.InstallImage)bin/agents/net6.0/nunit.engine.api.xml" />
</Component>
<Component Id="NUNIT_AGENT_NET60_ENGINE_CORE" Location="local" Guid="583A7D7E-9046-408C-8AA1-821EFCC2A7EA">
<File Id="nunit.agent.net60.engine.core.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/net6.0/nunit.engine.core.dll" />
Source="$(var.InstallImage)bin/agents/net6.0/nunit.engine.core.dll" />
</Component>
<Component Id="NUNIT_AGENT_NET60_ENGINE_METADATA" Location="local" Guid="8F00367C-4FFD-429D-8483-D5FA6D109627">
<File Id="nunit.agent.net60.engine.metadata.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/net6.0/testcentric.engine.metadata.dll" />
Source="$(var.InstallImage)bin/agents/net6.0/testcentric.engine.metadata.dll" />
</Component>
<Component Id="NUNIT_AGENT_NET60_DEPENDENCY_MODEL" Location="local" Guid="EFD82EAE-A38E-45E0-944B-A776F7353100">
<File Id="Microsoft.Extensions.DependencyModel.net60.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/net6.0/Microsoft.Extensions.DependencyModel.dll" />
Source="$(var.InstallImage)bin/agents/net6.0/Microsoft.Extensions.DependencyModel.dll" />
</Component>
</ComponentGroup>
<ComponentGroup Id="NET70_AGENT" Directory="NET70_AGENT_DIR">
<Component Id="NUNIT_AGENT_NET70" Location="local" Guid="F1B28B46-EBAE-4D3D-AFAB-9E60B0F35EDC">
<File Id="nunit_agent_net70.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net7.0/nunit-agent.dll" />
<File Id="nunit_agent_net70.dll.config"
Source="$(var.InstallImage)bin/agents/net7.0/nunit-agent.dll.config" />
<File Id="nunit_agent_net70.deps.json"
Source="$(var.InstallImage)bin/agents/net7.0/nunit-agent.deps.json" />
<File Id="nunit_agent_net70.runtimeconfig.json"
Source="$(var.InstallImage)bin/agents/net7.0/nunit-agent.runtimeconfig.json" />
</Component>
<Component Id="NUNIT_AGENT_NET70_ENGINE_API" Location="local" Guid="03667196-96FA-4AE9-8A1B-6059FA520CD9">
<File Id="nunit.agent.net70.engine.api.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net7.0/nunit.engine.api.dll" />
<File Id="nunit.agent.net70.engine.api.xml"
Source="$(var.InstallImage)bin/agents/net7.0/nunit.engine.api.xml" />
</Component>
<Component Id="NUNIT_AGENT_NET70_ENGINE_CORE" Location="local" Guid="1CA60508-6E99-4FD5-AE90-023EC61C2CDB">
<File Id="nunit.agent.net70.engine.core.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net7.0/nunit.engine.core.dll" />
</Component>
<Component Id="NUNIT_AGENT_NET70_ENGINE_METADATA" Location="local" Guid="B2BEE75C-2BCA-4D81-BA23-64F309A5B45D">
<File Id="nunit.agent.net70.engine.metadata.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net7.0/testcentric.engine.metadata.dll" />
</Component>
<Component Id="NUNIT_AGENT_NET70_DEPENDENCY_MODEL" Location="local" Guid="B6C3D2CF-8441-4479-8EDE-A4E76A487F63">
<File Id="Microsoft.Extensions.DependencyModel.net70.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net7.0/Microsoft.Extensions.DependencyModel.dll" />
</Component>
</ComponentGroup>
<ComponentGroup Id="NET80_AGENT" Directory="NET80_AGENT_DIR">
<Component Id="NUNIT_AGENT_NET80" Location="local" Guid="D8F8C2FB-E60E-455E-9C6A-B715268F3260">
<File Id="nunit_agent_net80.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net8.0/nunit-agent.dll" />
<File Id="nunit_agent_net80.dll.config"
Source="$(var.InstallImage)bin/agents/net8.0/nunit-agent.dll.config" />
<File Id="nunit_agent_net80.deps.json"
Source="$(var.InstallImage)bin/agents/net8.0/nunit-agent.deps.json" />
<File Id="nunit_agent_net80.runtimeconfig.json"
Source="$(var.InstallImage)bin/agents/net8.0/nunit-agent.runtimeconfig.json" />
</Component>
<Component Id="NUNIT_AGENT_NET80_ENGINE_API" Location="local" Guid="74172ECE-BEE7-4961-9A6A-DA0D06120C88">
<File Id="nunit.agent.net80.engine.api.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net8.0/nunit.engine.api.dll" />
<File Id="nunit.agent.net80.engine.api.xml"
Source="$(var.InstallImage)bin/net8.0/nunit.engine.api.xml" />
</Component>
<Component Id="NUNIT_AGENT_NET80_ENGINE_CORE" Location="local" Guid="A24E77FD-350C-4E6C-B467-A7877CF9D656">
<File Id="nunit.agent.net80.engine.core.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net8.0/nunit.engine.core.dll" />
</Component>
<Component Id="NUNIT_AGENT_NET80_ENGINE_METADATA" Location="local" Guid="CFE58B66-97D3-434D-A929-638D07F23D94">
<File Id="nunit.agent.net80.engine.metadata.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net8.0/testcentric.engine.metadata.dll" />
</Component>
<Component Id="NUNIT_AGENT_NET80_DEPENDENCY_MODEL" Location="local" Guid="F3B15759-D568-430E-84A2-773CB9E9BBBA">
<File Id="Microsoft.Extensions.DependencyModel.net80.dll"
ProcessorArchitecture="msil"
Source="$(var.InstallImage)bin/agents/net8.0/Microsoft.Extensions.DependencyModel.dll" />
</Component>
</ComponentGroup>
</Fragment>
Expand Down
2 changes: 2 additions & 0 deletions msi/nunit/runner-directories.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<Directory Id="NETCORE31_AGENT_DIR" Name="netcoreapp3.1" />
<Directory Id="NET50_AGENT_DIR" Name="net5.0" />
<Directory Id="NET60_AGENT_DIR" Name="net6.0" />
<Directory Id="NET70_AGENT_DIR" Name="net7.0" />
<Directory Id="NET80_AGENT_DIR" Name="net8.0" />
</Directory>
</Directory>
</DirectoryRef>
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitEngine/mock-assembly-x86/mock-assembly-x86.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<RootNamespace>NUnit.Tests</RootNamespace>
<TargetFrameworks>net35;net40;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net35;net40;netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
<PlatformTarget>x86</PlatformTarget>
Expand Down
3 changes: 2 additions & 1 deletion src/NUnitEngine/nunit.engine.api/IRuntimeFrameworkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ public interface IRuntimeFrameworkService
/// the string passed as an argument is available.
/// </summary>
/// <param name="framework">A string representing a framework, like 'net-4.0'</param>
/// <param name="x86">A flag indicating whether the X86 architecture is needed. Defaults to false.</param>
/// <returns>True if the framework is available, false if unavailable or nonexistent</returns>
bool IsAvailable(string framework);
bool IsAvailable(string framework, bool x86);

/// <summary>
/// Selects a target runtime framework for a TestPackage based on
Expand Down
Loading