Fix running on macos via .app
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using Microsoft.Build.Locator;
|
||||||
|
|
||||||
|
namespace SharpIDE.Application.Features.Build;
|
||||||
|
|
||||||
|
public static class SharpIdeMsbuildLocator
|
||||||
|
{
|
||||||
|
public static void Register()
|
||||||
|
{
|
||||||
|
if (OperatingSystem.IsMacOS())
|
||||||
|
{
|
||||||
|
FixMacosPath();
|
||||||
|
}
|
||||||
|
// Use latest version - https://github.com/microsoft/MSBuildLocator/issues/81
|
||||||
|
var instance = MSBuildLocator.QueryVisualStudioInstances().MaxBy(s => s.Version);
|
||||||
|
if (instance is null) throw new InvalidOperationException("No MSBuild instances found");
|
||||||
|
MSBuildLocator.RegisterInstance(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/microsoft/MSBuildLocator/issues/361
|
||||||
|
private static void FixMacosPath()
|
||||||
|
{
|
||||||
|
var processStartInfo = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "/bin/zsh",
|
||||||
|
ArgumentList = { "-l", "-c", "printenv PATH" },
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true,
|
||||||
|
UseShellExecute = false,
|
||||||
|
};
|
||||||
|
using var process = Process.Start(processStartInfo);
|
||||||
|
var output = process!.StandardOutput.ReadToEnd().Trim();
|
||||||
|
process.WaitForExit();
|
||||||
|
Environment.SetEnvironmentVariable("PATH", output, EnvironmentVariableTarget.Process);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Microsoft.Build.Locator;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using SharpIDE.Application.Features.Events;
|
using SharpIDE.Application.Features.Build;
|
||||||
using SharpIDE.Application.Features.FilePersistence;
|
|
||||||
using SharpIDE.Godot.Features.IdeSettings;
|
using SharpIDE.Godot.Features.IdeSettings;
|
||||||
using SharpIDE.Godot.Features.SlnPicker;
|
using SharpIDE.Godot.Features.SlnPicker;
|
||||||
|
|
||||||
@@ -26,10 +24,7 @@ public partial class IdeWindow : Control
|
|||||||
GD.Print("IdeWindow _Ready called");
|
GD.Print("IdeWindow _Ready called");
|
||||||
ResourceLoader.LoadThreadedRequest(SlnPickerScenePath);
|
ResourceLoader.LoadThreadedRequest(SlnPickerScenePath);
|
||||||
ResourceLoader.LoadThreadedRequest(IdeRootScenePath);
|
ResourceLoader.LoadThreadedRequest(IdeRootScenePath);
|
||||||
// Use latest version - https://github.com/microsoft/MSBuildLocator/issues/81
|
SharpIdeMsbuildLocator.Register();
|
||||||
var instance = MSBuildLocator.QueryVisualStudioInstances().MaxBy(s => s.Version);
|
|
||||||
if (instance is null) throw new InvalidOperationException("No MSBuild instances found");
|
|
||||||
MSBuildLocator.RegisterInstance(instance);
|
|
||||||
GodotOtelExtensions.AddServiceDefaults();
|
GodotOtelExtensions.AddServiceDefaults();
|
||||||
Singletons.AppState = AppStateLoader.LoadAppStateFromConfigFile();
|
Singletons.AppState = AppStateLoader.LoadAppStateFromConfigFile();
|
||||||
//GetWindow().SetMinSize(new Vector2I(1152, 648));
|
//GetWindow().SetMinSize(new Vector2I(1152, 648));
|
||||||
|
|||||||
Reference in New Issue
Block a user