File tree Expand file tree Collapse file tree 2 files changed +38
-7
lines changed
SharpIDE.Application/Features/Build Expand file tree Collapse file tree 2 files changed +38
-7
lines changed Original file line number Diff line number Diff line change 1+ using System . Diagnostics ;
2+ using Microsoft . Build . Locator ;
3+
4+ namespace SharpIDE . Application . Features . Build ;
5+
6+ public static class SharpIdeMsbuildLocator
7+ {
8+ public static void Register ( )
9+ {
10+ if ( OperatingSystem . IsMacOS ( ) )
11+ {
12+ FixMacosPath ( ) ;
13+ }
14+ // Use latest version - https://github.com/microsoft/MSBuildLocator/issues/81
15+ var instance = MSBuildLocator . QueryVisualStudioInstances ( ) . MaxBy ( s => s . Version ) ;
16+ if ( instance is null ) throw new InvalidOperationException ( "No MSBuild instances found" ) ;
17+ MSBuildLocator . RegisterInstance ( instance ) ;
18+ }
19+
20+ // https://github.com/microsoft/MSBuildLocator/issues/361
21+ private static void FixMacosPath ( )
22+ {
23+ var processStartInfo = new ProcessStartInfo
24+ {
25+ FileName = "/bin/zsh" ,
26+ ArgumentList = { "-l" , "-c" , "printenv PATH" } ,
27+ RedirectStandardOutput = true ,
28+ RedirectStandardError = true ,
29+ UseShellExecute = false ,
30+ } ;
31+ using var process = Process . Start ( processStartInfo ) ;
32+ var output = process ! . StandardOutput . ReadToEnd ( ) . Trim ( ) ;
33+ process . WaitForExit ( ) ;
34+ Environment . SetEnvironmentVariable ( "PATH" , output , EnvironmentVariableTarget . Process ) ;
35+ }
36+ }
Original file line number Diff line number Diff line change 11using Godot ;
2- using Microsoft . Build . Locator ;
32using Microsoft . Extensions . Hosting ;
4- using SharpIDE . Application . Features . Events ;
5- using SharpIDE . Application . Features . FilePersistence ;
3+ using SharpIDE . Application . Features . Build ;
64using SharpIDE . Godot . Features . IdeSettings ;
75using SharpIDE . Godot . Features . SlnPicker ;
86
@@ -26,10 +24,7 @@ public override void _Ready()
2624 GD . Print ( "IdeWindow _Ready called" ) ;
2725 ResourceLoader . LoadThreadedRequest ( SlnPickerScenePath ) ;
2826 ResourceLoader . LoadThreadedRequest ( IdeRootScenePath ) ;
29- // Use latest version - https://github.com/microsoft/MSBuildLocator/issues/81
30- var instance = MSBuildLocator . QueryVisualStudioInstances ( ) . MaxBy ( s => s . Version ) ;
31- if ( instance is null ) throw new InvalidOperationException ( "No MSBuild instances found" ) ;
32- MSBuildLocator . RegisterInstance ( instance ) ;
27+ SharpIdeMsbuildLocator . Register ( ) ;
3328 GodotOtelExtensions . AddServiceDefaults ( ) ;
3429 Singletons . AppState = AppStateLoader . LoadAppStateFromConfigFile ( ) ;
3530 //GetWindow().SetMinSize(new Vector2I(1152, 648));
You can’t perform that action at this time.
0 commit comments