File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
modules/mono/editor/GodotTools Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 11using System ;
2+ using System . Linq ;
23using Microsoft . Build . Construction ;
4+ using Microsoft . Build . Locator ;
35
46namespace GodotTools . ProjectEditor
57{
@@ -19,15 +21,18 @@ public MSBuildProject(ProjectRootElement root)
1921
2022 public static class ProjectUtils
2123 {
22- public static void MSBuildLocatorRegisterDefaults ( out Version version , out string path )
24+ public static void MSBuildLocatorRegisterLatest ( out Version version , out string path )
2325 {
24- var instance = Microsoft . Build . Locator . MSBuildLocator . RegisterDefaults ( ) ;
26+ var instance = MSBuildLocator . QueryVisualStudioInstances ( )
27+ . OrderByDescending ( x => x . Version )
28+ . First ( ) ;
29+ MSBuildLocator . RegisterInstance ( instance ) ;
2530 version = instance . Version ;
2631 path = instance . MSBuildPath ;
2732 }
2833
2934 public static void MSBuildLocatorRegisterMSBuildPath ( string msbuildPath )
30- => Microsoft . Build . Locator . MSBuildLocator . RegisterMSBuildPath ( msbuildPath ) ;
35+ => MSBuildLocator . RegisterMSBuildPath ( msbuildPath ) ;
3136
3237 public static MSBuildProject Open ( string path )
3338 {
Original file line number Diff line number Diff line change @@ -456,7 +456,7 @@ public override void _EnablePlugin()
456456 var dotNetSdkSearchVersion = Environment . Version ;
457457
458458 // First we try to find the .NET Sdk ourselves to make sure we get the
459- // correct version first (`RegisterDefaults` always picks the latest) .
459+ // correct version first, otherwise pick the latest.
460460 if ( DotNetFinder . TryFindDotNetSdk ( dotNetSdkSearchVersion , out var sdkVersion , out string sdkPath ) )
461461 {
462462 if ( Godot . OS . IsStdOutVerbose ( ) )
@@ -468,7 +468,7 @@ public override void _EnablePlugin()
468468 {
469469 try
470470 {
471- ProjectUtils . MSBuildLocatorRegisterDefaults ( out sdkVersion , out sdkPath ) ;
471+ ProjectUtils . MSBuildLocatorRegisterLatest ( out sdkVersion , out sdkPath ) ;
472472 if ( Godot . OS . IsStdOutVerbose ( ) )
473473 Console . WriteLine ( $ "Found .NET Sdk version '{ sdkVersion } ': { sdkPath } ") ;
474474 }
You can’t perform that action at this time.
0 commit comments