You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
C#: Fallback to the latest SDK
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using Microsoft.Build.Construction;
|
using Microsoft.Build.Construction;
|
||||||
|
using Microsoft.Build.Locator;
|
||||||
|
|
||||||
namespace GodotTools.ProjectEditor
|
namespace GodotTools.ProjectEditor
|
||||||
{
|
{
|
||||||
@@ -19,15 +21,18 @@ namespace GodotTools.ProjectEditor
|
|||||||
|
|
||||||
public static class ProjectUtils
|
public static class ProjectUtils
|
||||||
{
|
{
|
||||||
public static void MSBuildLocatorRegisterDefaults(out Version version, out string path)
|
public static void MSBuildLocatorRegisterLatest(out Version version, out string path)
|
||||||
{
|
{
|
||||||
var instance = Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults();
|
var instance = MSBuildLocator.QueryVisualStudioInstances()
|
||||||
|
.OrderByDescending(x => x.Version)
|
||||||
|
.First();
|
||||||
|
MSBuildLocator.RegisterInstance(instance);
|
||||||
version = instance.Version;
|
version = instance.Version;
|
||||||
path = instance.MSBuildPath;
|
path = instance.MSBuildPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MSBuildLocatorRegisterMSBuildPath(string msbuildPath)
|
public static void MSBuildLocatorRegisterMSBuildPath(string msbuildPath)
|
||||||
=> Microsoft.Build.Locator.MSBuildLocator.RegisterMSBuildPath(msbuildPath);
|
=> MSBuildLocator.RegisterMSBuildPath(msbuildPath);
|
||||||
|
|
||||||
public static MSBuildProject Open(string path)
|
public static MSBuildProject Open(string path)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -456,7 +456,7 @@ namespace GodotTools
|
|||||||
var dotNetSdkSearchVersion = Environment.Version;
|
var dotNetSdkSearchVersion = Environment.Version;
|
||||||
|
|
||||||
// First we try to find the .NET Sdk ourselves to make sure we get the
|
// First we try to find the .NET Sdk ourselves to make sure we get the
|
||||||
// correct version first (`RegisterDefaults` always picks the latest).
|
// correct version first, otherwise pick the latest.
|
||||||
if (DotNetFinder.TryFindDotNetSdk(dotNetSdkSearchVersion, out var sdkVersion, out string sdkPath))
|
if (DotNetFinder.TryFindDotNetSdk(dotNetSdkSearchVersion, out var sdkVersion, out string sdkPath))
|
||||||
{
|
{
|
||||||
if (Godot.OS.IsStdOutVerbose())
|
if (Godot.OS.IsStdOutVerbose())
|
||||||
@@ -468,7 +468,7 @@ namespace GodotTools
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProjectUtils.MSBuildLocatorRegisterDefaults(out sdkVersion, out sdkPath);
|
ProjectUtils.MSBuildLocatorRegisterLatest(out sdkVersion, out sdkPath);
|
||||||
if (Godot.OS.IsStdOutVerbose())
|
if (Godot.OS.IsStdOutVerbose())
|
||||||
Console.WriteLine($"Found .NET Sdk version '{sdkVersion}': {sdkPath}");
|
Console.WriteLine($"Found .NET Sdk version '{sdkVersion}': {sdkPath}");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user