Skip to content

Commit

Permalink
Merge pull request #1268 from nunit/issue-1182
Browse files Browse the repository at this point in the history
Don't throw exception when VS Solution contains a .NET Standard assembly
  • Loading branch information
CharliePoole authored Nov 14, 2022
2 parents 7ff4501 + f76d141 commit 00d8d5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected override TestEngineResult LoadPackage()
{
var testFile = subPackage.FullName;

string targetFramework = subPackage.GetSetting(InternalEnginePackageSettings.ImageTargetFrameworkName, (string)null);
string targetFramework = subPackage.GetSetting(EnginePackageSettings.TargetRuntimeFramework, (string)null);
bool skipNonTestAssemblies = subPackage.GetSetting(EnginePackageSettings.SkipNonTestAssemblies, false);

if (_assemblyResolver != null && !TestDomain.IsDefaultAppDomain()
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 @@ -130,7 +130,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 @@ -142,15 +142,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 (!new RuntimeFramework(targetRuntime, targetVersion).IsAvailable)
Expand Down

0 comments on commit 00d8d5e

Please sign in to comment.