Merge pull request #44135 from neikeq/godot-net-sdk-fixes-n-impr
Godot.NET.Sdk/3.2.4 - Fix targeting .NETFramework with .NET 5
This commit is contained in:
commit
0b5a9bf716
6 changed files with 36 additions and 20 deletions
|
@ -6,8 +6,8 @@
|
||||||
<Authors>Godot Engine contributors</Authors>
|
<Authors>Godot Engine contributors</Authors>
|
||||||
|
|
||||||
<PackageId>Godot.NET.Sdk</PackageId>
|
<PackageId>Godot.NET.Sdk</PackageId>
|
||||||
<Version>3.2.3</Version>
|
<Version>3.2.4</Version>
|
||||||
<PackageVersion>3.2.3</PackageVersion>
|
<PackageVersion>3.2.4</PackageVersion>
|
||||||
<PackageProjectUrl>https://github.com/godotengine/godot/tree/master/modules/mono/editor/Godot.NET.Sdk</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/godotengine/godot/tree/master/modules/mono/editor/Godot.NET.Sdk</PackageProjectUrl>
|
||||||
<PackageType>MSBuildSdk</PackageType>
|
<PackageType>MSBuildSdk</PackageType>
|
||||||
<PackageTags>MSBuildSdk</PackageTags>
|
<PackageTags>MSBuildSdk</PackageTags>
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- Determines if we should import Microsoft.NET.Sdk, if it wasn't already imported. -->
|
<!-- Determines if we should import Microsoft.NET.Sdk, if it wasn't already imported. -->
|
||||||
<GodotSdkImportsMicrosoftNetSdk Condition=" '$(UsingMicrosoftNETSdk)' != 'true' ">true</GodotSdkImportsMicrosoftNetSdk>
|
<GodotSdkImportsMicrosoftNetSdk Condition=" '$(UsingMicrosoftNETSdk)' != 'true' ">true</GodotSdkImportsMicrosoftNetSdk>
|
||||||
|
|
||||||
<GodotProjectTypeGuid>{8F3E2DF0-C35C-4265-82FC-BEA011F4A7ED}</GodotProjectTypeGuid>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
<Project>
|
<Project>
|
||||||
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" Condition=" '$(GodotSdkImportsMicrosoftNetSdk)' == 'true' " />
|
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" Condition=" '$(GodotSdkImportsMicrosoftNetSdk)' == 'true' " />
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<EnableGodotProjectTypeGuid Condition=" '$(EnableGodotProjectTypeGuid)' == '' ">true</EnableGodotProjectTypeGuid>
|
|
||||||
<ProjectTypeGuids Condition=" '$(EnableGodotProjectTypeGuid)' == 'true' ">$(GodotProjectTypeGuid);$(DefaultProjectTypeGuid)</ProjectTypeGuids>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!--
|
<!--
|
||||||
Define constant to determine whether the real_t type in Godot is double precision or not.
|
Define constant to determine whether the real_t type in Godot is double precision or not.
|
||||||
|
@ -16,7 +11,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Backported from newer Microsoft.NET.Sdk version -->
|
<!-- Backported from newer Microsoft.NET.Sdk version -->
|
||||||
<Target Name="IncludeTargetingPackReference" BeforeTargets="_GetRestoreSettingsPerFramework;_CheckForInvalidConfigurationAndPlatform"
|
<Target Name="GodotIncludeTargetingPackReference" BeforeTargets="_GetRestoreSettingsPerFramework;_CheckForInvalidConfigurationAndPlatform"
|
||||||
Condition=" '$(GodotUseNETFrameworkRefAssemblies)' == 'true' and '$(TargetFrameworkMoniker)' != '' and '$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(AutomaticallyUseReferenceAssemblyPackages)' == 'true' ">
|
Condition=" '$(GodotUseNETFrameworkRefAssemblies)' == 'true' and '$(TargetFrameworkMoniker)' != '' and '$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(AutomaticallyUseReferenceAssemblyPackages)' == 'true' ">
|
||||||
<GetReferenceAssemblyPaths
|
<GetReferenceAssemblyPaths
|
||||||
TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
|
TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.Build" />
|
<Reference Include="Microsoft.Build" />
|
||||||
<PackageReference Include="Microsoft.Build" Version="16.5.0" />
|
<PackageReference Include="Microsoft.Build" Version="16.5.0" />
|
||||||
|
<PackageReference Include="semver" Version="2.0.6" />
|
||||||
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3.0" ExcludeAssets="runtime" PrivateAssets="all" />
|
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3.0" ExcludeAssets="runtime" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -8,9 +8,8 @@ namespace GodotTools.ProjectEditor
|
||||||
{
|
{
|
||||||
public static class ProjectGenerator
|
public static class ProjectGenerator
|
||||||
{
|
{
|
||||||
public const string GodotSdkVersionToUse = "3.2.3";
|
public const string GodotSdkVersionToUse = "3.2.4";
|
||||||
|
public const string GodotSdkNameToUse = "Godot.NET.Sdk";
|
||||||
public static string GodotSdkAttrValue => $"Godot.NET.Sdk/{GodotSdkVersionToUse}";
|
|
||||||
|
|
||||||
public static ProjectRootElement GenGameProject(string name)
|
public static ProjectRootElement GenGameProject(string name)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +18,7 @@ namespace GodotTools.ProjectEditor
|
||||||
|
|
||||||
var root = ProjectRootElement.Create(NewProjectFileOptions.None);
|
var root = ProjectRootElement.Create(NewProjectFileOptions.None);
|
||||||
|
|
||||||
root.Sdk = GodotSdkAttrValue;
|
root.Sdk = $"{GodotSdkNameToUse}/{GodotSdkVersionToUse}";
|
||||||
|
|
||||||
var mainGroup = root.AddPropertyGroup();
|
var mainGroup = root.AddPropertyGroup();
|
||||||
mainGroup.AddProperty("TargetFramework", "net472");
|
mainGroup.AddProperty("TargetFramework", "net472");
|
||||||
|
|
|
@ -4,11 +4,13 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Microsoft.Build.Construction;
|
using Microsoft.Build.Construction;
|
||||||
using Microsoft.Build.Globbing;
|
using Microsoft.Build.Globbing;
|
||||||
|
using Semver;
|
||||||
|
|
||||||
namespace GodotTools.ProjectEditor
|
namespace GodotTools.ProjectEditor
|
||||||
{
|
{
|
||||||
|
@ -189,7 +191,7 @@ namespace GodotTools.ProjectEditor
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
string normalizedRemove= item.Remove.NormalizePath();
|
string normalizedRemove = item.Remove.NormalizePath();
|
||||||
|
|
||||||
var glob = MSBuildGlob.Parse(normalizedRemove);
|
var glob = MSBuildGlob.Parse(normalizedRemove);
|
||||||
|
|
||||||
|
@ -233,7 +235,7 @@ namespace GodotTools.ProjectEditor
|
||||||
if (!string.IsNullOrEmpty(root.Sdk))
|
if (!string.IsNullOrEmpty(root.Sdk))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
root.Sdk = ProjectGenerator.GodotSdkAttrValue;
|
root.Sdk = $"{ProjectGenerator.GodotSdkNameToUse}/{ProjectGenerator.GodotSdkVersionToUse}";
|
||||||
|
|
||||||
root.ToolsVersion = null;
|
root.ToolsVersion = null;
|
||||||
root.DefaultTargets = null;
|
root.DefaultTargets = null;
|
||||||
|
@ -408,12 +410,33 @@ namespace GodotTools.ProjectEditor
|
||||||
|
|
||||||
public static void EnsureGodotSdkIsUpToDate(MSBuildProject project)
|
public static void EnsureGodotSdkIsUpToDate(MSBuildProject project)
|
||||||
{
|
{
|
||||||
var root = project.Root;
|
string godotSdkAttrValue = $"{ProjectGenerator.GodotSdkNameToUse}/{ProjectGenerator.GodotSdkVersionToUse}";
|
||||||
string godotSdkAttrValue = ProjectGenerator.GodotSdkAttrValue;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(root.Sdk) && root.Sdk.Trim().Equals(godotSdkAttrValue, StringComparison.OrdinalIgnoreCase))
|
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;
|
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}/(?<ver>.*)$");
|
||||||
|
|
||||||
|
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;
|
root.Sdk = godotSdkAttrValue;
|
||||||
project.HasUnsavedChanges = true;
|
project.HasUnsavedChanges = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue