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

Fix exception for .NET standard assemblies and add a test #1423

Merged
merged 2 commits into from
Jun 12, 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 cake/package-tests.cake
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static PackageTest Net60Test = new PackageTest(
static PackageTest Net60X86Test = new PackageTest(
"Net60X86Test",
"Run mock-assembly-x86.dll under .NET 6.0",
"net6.0/mock-assembly-x86.dll --trace:Debug",
"net6.0/mock-assembly-x86.dll",
MockAssemblyExpectedResult(1));

static PackageTest Net50Test = new PackageTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void ServiceIsStarted()
[TestCase("mock-assembly.dll", false)]
[TestCase("../agents/net20/nunit-agent.exe", false)]
[TestCase("../agents/net20/nunit-agent-x86.exe", true)]
[TestCase("../netstandard2.0/nunit.engine.api.dll", false)]
public void SelectRuntimeFramework(string assemblyName, bool runAsX86)
{
var package = new TestPackage(Path.Combine(TestContext.CurrentContext.TestDirectory, assemblyName));
Expand Down
10 changes: 7 additions & 3 deletions src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private RuntimeFramework SelectRuntimeFrameworkInner(TestPackage package)

if (string.IsNullOrEmpty(imageTargetFrameworkNameSetting))
{
// Assume .NET Framework
// Assume .NET Framework 2.0
targetRuntime = currentFramework.Runtime;
targetVersion = package.GetSetting(InternalEnginePackageSettings.ImageRuntimeVersion, new Version(2, 0));
}
Expand All @@ -152,15 +152,19 @@ private RuntimeFramework SelectRuntimeFrameworkInner(TestPackage package)
{
case ".NETFramework":
targetRuntime = RuntimeType.Net;
targetVersion = frameworkName.Version;
break;
case ".NETCoreApp":
targetRuntime = RuntimeType.NetCore;
targetVersion = frameworkName.Version;
break;
case ".NETStandard":
targetRuntime = RuntimeType.NetCore;
targetVersion = new Version(3, 1);
break;
default:
throw new NUnitEngineException("Unsupported Target Framework: " + imageTargetFrameworkNameSetting);
}

targetVersion = frameworkName.Version;
}

if (!IsAvailable(new RuntimeFramework(targetRuntime, targetVersion).Id, runAsX86))
Expand Down