diff --git a/src/NUnitEngine/nunit.engine.core/Internal/RuntimeFrameworks/NetCoreFrameworkLocator.cs b/src/NUnitEngine/nunit.engine.core/Internal/RuntimeFrameworks/NetCoreFrameworkLocator.cs index 71eff1cf6..420dd4a6a 100644 --- a/src/NUnitEngine/nunit.engine.core/Internal/RuntimeFrameworks/NetCoreFrameworkLocator.cs +++ b/src/NUnitEngine/nunit.engine.core/Internal/RuntimeFrameworks/NetCoreFrameworkLocator.cs @@ -12,6 +12,8 @@ namespace NUnit.Engine.Internal.RuntimeFrameworks { internal static class NetCoreFrameworkLocator { + static Logger log = InternalTrace.GetLogger(typeof(NetCoreFrameworkLocator)); + public static IEnumerable FindDotNetCoreFrameworks() { List alreadyFound = new List(); @@ -22,7 +24,12 @@ public static IEnumerable FindDotNetCoreFrameworks() if (TryGetVersionFromString(dirName, out newVersion) && !alreadyFound.Contains(newVersion)) { alreadyFound.Add(newVersion); - yield return new RuntimeFramework(RuntimeType.NetCore, newVersion); + // HACK: Avoid Exception for an unknown version - see issue #1223 + // Requires change in RuntimeFramework.GetClrVersionForFramework() + if (newVersion.Major <= 7) + yield return new RuntimeFramework(RuntimeType.NetCore, newVersion); + else + log.Error($"Found .NET {newVersion.ToString(2)}, which is not yet supported."); } } diff --git a/src/NUnitEngine/nunit.engine.core/RuntimeFramework.cs b/src/NUnitEngine/nunit.engine.core/RuntimeFramework.cs index 569f6b930..42782f462 100644 --- a/src/NUnitEngine/nunit.engine.core/RuntimeFramework.cs +++ b/src/NUnitEngine/nunit.engine.core/RuntimeFramework.cs @@ -134,6 +134,7 @@ public RuntimeFramework(RuntimeType runtime, Version version, string profile) // Version 0.0 means any version so we can't deduce anything if (version != DefaultVersion) { + Debug.Assert(IsFrameworkVersion(version)); if (IsFrameworkVersion(version)) ClrVersion = GetClrVersionForFramework(version); else diff --git a/src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs b/src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs index bd5cecf99..5347ec49d 100644 --- a/src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs +++ b/src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs @@ -173,27 +173,6 @@ private RuntimeFramework SelectRuntimeFrameworkInner(TestPackage package) return targetFramework; } - - /// - /// Returns the best available framework that matches a target framework. - /// If the target framework has a build number specified, then an exact - /// match is needed. Otherwise, the matching framework with the highest - /// build number is used. - /// - public RuntimeFramework GetBestAvailableFramework(RuntimeFramework target) - { - RuntimeFramework result = target; - - foreach (RuntimeFramework framework in _availableRuntimes) - if (framework.Supports(target)) - { - if (framework.ClrVersion.Build > result.ClrVersion.Build) - result = framework; - } - - return result; - } - /// /// Use Mono.Cecil to get information about all assemblies and /// apply it to the package using special internal keywords.