diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj index 81a2172b911..a460685cac3 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj @@ -6,8 +6,8 @@ Godot Engine contributors Godot.NET.Sdk - 3.2.3 - 3.2.3 + 3.2.4 + 3.2.4 https://github.com/godotengine/godot/tree/master/modules/mono/editor/Godot.NET.Sdk MSBuildSdk MSBuildSdk diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props index a965456a047..c9d90f4810e 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props @@ -2,8 +2,6 @@ true - - {8F3E2DF0-C35C-4265-82FC-BEA011F4A7ED} diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets index b9c17bad1e2..480b5109b1b 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets @@ -1,11 +1,6 @@ - - true - $(GodotProjectTypeGuid);$(DefaultProjectTypeGuid) - - - + diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs index 7e795ec016d..5f54bb4d9aa 100644 --- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs +++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs @@ -8,9 +8,8 @@ namespace GodotTools.ProjectEditor { public static class ProjectGenerator { - public const string GodotSdkVersionToUse = "3.2.3"; - - public static string GodotSdkAttrValue => $"Godot.NET.Sdk/{GodotSdkVersionToUse}"; + public const string GodotSdkVersionToUse = "3.2.4"; + public const string GodotSdkNameToUse = "Godot.NET.Sdk"; public static ProjectRootElement GenGameProject(string name) { @@ -19,7 +18,7 @@ namespace GodotTools.ProjectEditor var root = ProjectRootElement.Create(NewProjectFileOptions.None); - root.Sdk = GodotSdkAttrValue; + root.Sdk = $"{GodotSdkNameToUse}/{GodotSdkVersionToUse}"; var mainGroup = root.AddPropertyGroup(); mainGroup.AddProperty("TargetFramework", "net472"); diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs index ba3772c9388..742f8c616e9 100644 --- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs +++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs @@ -4,11 +4,13 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Text.RegularExpressions; using System.Xml; using System.Xml.Linq; using JetBrains.Annotations; using Microsoft.Build.Construction; using Microsoft.Build.Globbing; +using Semver; namespace GodotTools.ProjectEditor { @@ -189,7 +191,7 @@ namespace GodotTools.ProjectEditor continue; - string normalizedRemove= item.Remove.NormalizePath(); + string normalizedRemove = item.Remove.NormalizePath(); var glob = MSBuildGlob.Parse(normalizedRemove); @@ -233,7 +235,7 @@ namespace GodotTools.ProjectEditor if (!string.IsNullOrEmpty(root.Sdk)) return; - root.Sdk = ProjectGenerator.GodotSdkAttrValue; + root.Sdk = $"{ProjectGenerator.GodotSdkNameToUse}/{ProjectGenerator.GodotSdkVersionToUse}"; root.ToolsVersion = null; root.DefaultTargets = null; @@ -408,11 +410,32 @@ namespace GodotTools.ProjectEditor public static void EnsureGodotSdkIsUpToDate(MSBuildProject project) { - var root = project.Root; - string godotSdkAttrValue = ProjectGenerator.GodotSdkAttrValue; + string godotSdkAttrValue = $"{ProjectGenerator.GodotSdkNameToUse}/{ProjectGenerator.GodotSdkVersionToUse}"; - if (!string.IsNullOrEmpty(root.Sdk) && root.Sdk.Trim().Equals(godotSdkAttrValue, StringComparison.OrdinalIgnoreCase)) - return; + var root = project.Root; + string rootSdk = root.Sdk?.Trim(); + + if (!string.IsNullOrEmpty(rootSdk)) + { + // Check if the version is already the same. + if (rootSdk.Equals(godotSdkAttrValue, StringComparison.OrdinalIgnoreCase)) + return; + + // We also allow higher versions as long as the major and minor are the same. + var semVerToUse = SemVersion.Parse(ProjectGenerator.GodotSdkVersionToUse); + var godotSdkAttrLaxValueRegex = new Regex($@"^{ProjectGenerator.GodotSdkNameToUse}/(?.*)$"); + + var match = godotSdkAttrLaxValueRegex.Match(rootSdk); + + if (match.Success && + SemVersion.TryParse(match.Groups["ver"].Value, out var semVerDetected) && + semVerDetected.Major == semVerToUse.Major && + semVerDetected.Minor == semVerToUse.Minor && + semVerDetected > semVerToUse) + { + return; + } + } root.Sdk = godotSdkAttrValue; project.HasUnsavedChanges = true;