diff options
author | Rodrigo Moya <rodrigo.moya@xamarin.com> | 2019-11-28 01:10:38 +0300 |
---|---|---|
committer | Rodrigo Moya <rodrigo.moya@xamarin.com> | 2019-11-28 02:23:23 +0300 |
commit | 3a7550df0cbc74c9d2e39a54ba0f07150ecdba1e (patch) | |
tree | 201351921792e034d2adca6a532835681a866a0a /main/src/addins/MonoDevelop.DotNetCore | |
parent | 554ce92ed654977985e14b4f5a8ebc612a3b16a6 (diff) |
[DotNetCore] Ignore unsupported SDKs in template wizard
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1008333
Diffstat (limited to 'main/src/addins/MonoDevelop.DotNetCore')
3 files changed, 25 insertions, 7 deletions
diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Templating/DotNetCoreProjectTemplateWizard.cs b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Templating/DotNetCoreProjectTemplateWizard.cs index cfe5ee2ad7..41e3ce3b1e 100644 --- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Templating/DotNetCoreProjectTemplateWizard.cs +++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore.Templating/DotNetCoreProjectTemplateWizard.cs @@ -87,6 +87,8 @@ namespace MonoDevelop.DotNetCore.Templating } else { targetFrameworks = DotNetCoreProjectSupportedTargetFrameworks.GetNetCoreAppTargetFrameworksWithSdkSupport ().ToList (); + RemoveUnsupportedNetCoreAppTargetFrameworks (targetFrameworks); + if (!SupportsNetCore2x ()) { RemoveUnsupportedNetCoreApp2xTargetFrameworks (targetFrameworks); } @@ -105,6 +107,11 @@ namespace MonoDevelop.DotNetCore.Templating targetFrameworks.RemoveAll (framework => framework.IsLowerThanNetStandard16 ()); } + static void RemoveUnsupportedNetCoreAppTargetFrameworks (List<TargetFramework> targetFrameworks) + { + targetFrameworks.RemoveAll (framework => framework.IsNetCoreAppOrHigher (DotNetCoreSdk.DotNetCoreUnsupportedTargetFrameworkVersion)); + } + /// <summary> /// FSharp class library project template and the Razor Pages project template do not support /// targeting 1.x versions so remove these frameworks. diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreSdk.cs b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreSdk.cs index 50992bf057..63dc50df57 100644 --- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreSdk.cs +++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/DotNetCoreSdk.cs @@ -36,6 +36,7 @@ namespace MonoDevelop.DotNetCore public static class DotNetCoreSdk { static readonly Version DotNetCoreVersion2_1 = new Version (2, 1, 0); + internal static readonly DotNetCoreVersion DotNetCoreUnsupportedTargetFrameworkVersion = new DotNetCoreVersion (3, 2, 0); static DotNetCoreSdk () { diff --git a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/TargetFrameworkMonikerExtensions.cs b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/TargetFrameworkMonikerExtensions.cs index 0e52b80399..71c92e557c 100644 --- a/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/TargetFrameworkMonikerExtensions.cs +++ b/main/src/addins/MonoDevelop.DotNetCore/MonoDevelop.DotNetCore/TargetFrameworkMonikerExtensions.cs @@ -50,22 +50,32 @@ namespace MonoDevelop.DotNetCore return framework.IsNetStandard () || framework.IsNetCoreApp (); } - public static bool IsNetCoreAppOrHigher (this TargetFrameworkMoniker framework, DotNetCoreVersion version) + static bool IsVersionOrHigher (this TargetFrameworkMoniker framework, DotNetCoreVersion version) { DotNetCoreVersion.TryParse (framework.Version, out var dotNetCoreVersion); if (dotNetCoreVersion == null) return false; - return framework.IsNetCoreApp () && dotNetCoreVersion >= version; + // Only compare $major.$minor, as Version parsing sets some fields to -1 + // (Build), which gives false positives/negatives when comparing, for instance, + // 3.1.100-preview1-014459 with an unsupported 3.1, and we're really only + // interested in the target framework version, which only uses $major.$minor. + if (dotNetCoreVersion.Major > version.Major) + return true; + if (dotNetCoreVersion.Major < version.Major) + return false; + + return dotNetCoreVersion.Minor >= version.Minor; } - public static bool IsNetStandardOrHigher (this TargetFrameworkMoniker framework, DotNetCoreVersion version) + public static bool IsNetCoreAppOrHigher (this TargetFrameworkMoniker framework, DotNetCoreVersion version) { - DotNetCoreVersion.TryParse (framework.Version, out var dotNetCoreVersion); - if (dotNetCoreVersion == null) - return false; + return framework.IsNetCoreApp () && framework.IsVersionOrHigher (version); + } - return framework.IsNetStandard () && dotNetCoreVersion >= version; + public static bool IsNetStandardOrHigher (this TargetFrameworkMoniker framework, DotNetCoreVersion version) + { + return framework.IsNetStandard () && framework.IsVersionOrHigher (version); } } } |