use Rider MSBuild on Windows, when Rider is selected as external editor
This commit is contained in:
parent
ed0f1940cb
commit
a9c2ab81cf
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
using GodotTools.Ides.Rider;
|
||||||
using GodotTools.Internals;
|
using GodotTools.Internals;
|
||||||
using Directory = System.IO.Directory;
|
using Directory = System.IO.Directory;
|
||||||
using Environment = System.Environment;
|
using Environment = System.Environment;
|
||||||
|
@ -54,6 +55,12 @@ namespace GodotTools.Build
|
||||||
|
|
||||||
return msbuildPath;
|
return msbuildPath;
|
||||||
}
|
}
|
||||||
|
case BuildManager.BuildTool.JetBrainsMsBuild:
|
||||||
|
var editorPath = (string)editorSettings.GetSetting(RiderPathManager.EditorPathSettingName);
|
||||||
|
if (!File.Exists(editorPath))
|
||||||
|
throw new FileNotFoundException($"Cannot find Rider executable. Tried with path: {editorPath}");
|
||||||
|
var riderDir = new FileInfo(editorPath).Directory.Parent;
|
||||||
|
return Path.Combine(riderDir.FullName, @"tools\MSBuild\Current\Bin\MSBuild.exe");
|
||||||
default:
|
default:
|
||||||
throw new IndexOutOfRangeException("Invalid build tool in editor settings");
|
throw new IndexOutOfRangeException("Invalid build tool in editor settings");
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using GodotTools.Build;
|
using GodotTools.Build;
|
||||||
|
using GodotTools.Ides.Rider;
|
||||||
using GodotTools.Internals;
|
using GodotTools.Internals;
|
||||||
using GodotTools.Utils;
|
using GodotTools.Utils;
|
||||||
using static GodotTools.Internals.Globals;
|
using static GodotTools.Internals.Globals;
|
||||||
|
@ -16,6 +17,7 @@ namespace GodotTools
|
||||||
|
|
||||||
public const string PropNameMsbuildMono = "MSBuild (Mono)";
|
public const string PropNameMsbuildMono = "MSBuild (Mono)";
|
||||||
public const string PropNameMsbuildVs = "MSBuild (VS Build Tools)";
|
public const string PropNameMsbuildVs = "MSBuild (VS Build Tools)";
|
||||||
|
public const string PropNameMsbuildJetBrains = "MSBuild (JetBrains Rider)";
|
||||||
|
|
||||||
public const string MsBuildIssuesFileName = "msbuild_issues.csv";
|
public const string MsBuildIssuesFileName = "msbuild_issues.csv";
|
||||||
public const string MsBuildLogFileName = "msbuild_log.txt";
|
public const string MsBuildLogFileName = "msbuild_log.txt";
|
||||||
|
@ -23,7 +25,8 @@ namespace GodotTools
|
||||||
public enum BuildTool
|
public enum BuildTool
|
||||||
{
|
{
|
||||||
MsBuildMono,
|
MsBuildMono,
|
||||||
MsBuildVs
|
MsBuildVs,
|
||||||
|
JetBrainsMsBuild
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RemoveOldIssuesFile(BuildInfo buildInfo)
|
private static void RemoveOldIssuesFile(BuildInfo buildInfo)
|
||||||
|
@ -181,7 +184,7 @@ namespace GodotTools
|
||||||
var buildInfo = new BuildInfo(GodotSharpDirs.ProjectSlnPath, config);
|
var buildInfo = new BuildInfo(GodotSharpDirs.ProjectSlnPath, config);
|
||||||
|
|
||||||
// Add Godot defines
|
// Add Godot defines
|
||||||
string constants = buildTool == BuildTool.MsBuildVs ? "GodotDefineConstants=\"" : "GodotDefineConstants=\\\"";
|
string constants = buildTool != BuildTool.MsBuildMono ? "GodotDefineConstants=\"" : "GodotDefineConstants=\\\"";
|
||||||
|
|
||||||
foreach (var godotDefine in godotDefines)
|
foreach (var godotDefine in godotDefines)
|
||||||
constants += $"GODOT_{godotDefine.ToUpper().Replace("-", "_").Replace(" ", "_").Replace(";", "_")};";
|
constants += $"GODOT_{godotDefine.ToUpper().Replace("-", "_").Replace(" ", "_").Replace(";", "_")};";
|
||||||
|
@ -189,7 +192,7 @@ namespace GodotTools
|
||||||
if (Internal.GodotIsRealTDouble())
|
if (Internal.GodotIsRealTDouble())
|
||||||
constants += "GODOT_REAL_T_IS_DOUBLE;";
|
constants += "GODOT_REAL_T_IS_DOUBLE;";
|
||||||
|
|
||||||
constants += buildTool == BuildTool.MsBuildVs ? "\"" : "\\\"";
|
constants += buildTool != BuildTool.MsBuildMono ? "\"" : "\\\"";
|
||||||
|
|
||||||
buildInfo.CustomProperties.Add(constants);
|
buildInfo.CustomProperties.Add(constants);
|
||||||
|
|
||||||
|
@ -245,10 +248,14 @@ namespace GodotTools
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
// Build tool settings
|
// Build tool settings
|
||||||
|
|
||||||
EditorDef("mono/builds/build_tool", OS.IsWindows ? BuildTool.MsBuildVs : BuildTool.MsBuildMono);
|
|
||||||
|
|
||||||
var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
|
var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
|
||||||
|
var msbuild = BuildTool.MsBuildMono;
|
||||||
|
if (OS.IsWindows)
|
||||||
|
msbuild = RiderPathManager.IsRider((string) editorSettings.GetSetting(RiderPathManager.EditorPathSettingName))
|
||||||
|
? BuildTool.JetBrainsMsBuild
|
||||||
|
: BuildTool.MsBuildVs;
|
||||||
|
|
||||||
|
EditorDef("mono/builds/build_tool", msbuild);
|
||||||
|
|
||||||
editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
|
editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
|
||||||
{
|
{
|
||||||
|
@ -256,7 +263,7 @@ namespace GodotTools
|
||||||
["name"] = "mono/builds/build_tool",
|
["name"] = "mono/builds/build_tool",
|
||||||
["hint"] = Godot.PropertyHint.Enum,
|
["hint"] = Godot.PropertyHint.Enum,
|
||||||
["hint_string"] = OS.IsWindows ?
|
["hint_string"] = OS.IsWindows ?
|
||||||
$"{PropNameMsbuildMono},{PropNameMsbuildVs}" :
|
$"{PropNameMsbuildMono},{PropNameMsbuildVs},{PropNameMsbuildJetBrains}" :
|
||||||
$"{PropNameMsbuildMono}"
|
$"{PropNameMsbuildMono}"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,13 @@ namespace GodotTools.Ides.Rider
|
||||||
{
|
{
|
||||||
public static class RiderPathManager
|
public static class RiderPathManager
|
||||||
{
|
{
|
||||||
private static readonly string editorPathSettingName = "mono/editor/editor_path_optional";
|
public static readonly string EditorPathSettingName = "mono/editor/editor_path_optional";
|
||||||
|
|
||||||
private static string GetRiderPathFromSettings()
|
private static string GetRiderPathFromSettings()
|
||||||
{
|
{
|
||||||
var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
|
var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings();
|
||||||
if (editorSettings.HasSetting(editorPathSettingName))
|
if (editorSettings.HasSetting(EditorPathSettingName))
|
||||||
return (string)editorSettings.GetSetting(editorPathSettingName);
|
return (string)editorSettings.GetSetting(EditorPathSettingName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,22 +25,22 @@ namespace GodotTools.Ides.Rider
|
||||||
var editor = (ExternalEditorId)editorSettings.GetSetting("mono/editor/external_editor");
|
var editor = (ExternalEditorId)editorSettings.GetSetting("mono/editor/external_editor");
|
||||||
if (editor == ExternalEditorId.Rider)
|
if (editor == ExternalEditorId.Rider)
|
||||||
{
|
{
|
||||||
if (!editorSettings.HasSetting(editorPathSettingName))
|
if (!editorSettings.HasSetting(EditorPathSettingName))
|
||||||
{
|
{
|
||||||
Globals.EditorDef(editorPathSettingName, "Optional");
|
Globals.EditorDef(EditorPathSettingName, "Optional");
|
||||||
editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
|
editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
|
||||||
{
|
{
|
||||||
["type"] = Variant.Type.String,
|
["type"] = Variant.Type.String,
|
||||||
["name"] = editorPathSettingName,
|
["name"] = EditorPathSettingName,
|
||||||
["hint"] = PropertyHint.File,
|
["hint"] = PropertyHint.File,
|
||||||
["hint_string"] = ""
|
["hint_string"] = ""
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var riderPath = (string)editorSettings.GetSetting(editorPathSettingName);
|
var riderPath = (string)editorSettings.GetSetting(EditorPathSettingName);
|
||||||
if (IsRiderAndExists(riderPath))
|
if (IsRiderAndExists(riderPath))
|
||||||
{
|
{
|
||||||
Globals.EditorDef(editorPathSettingName, riderPath);
|
Globals.EditorDef(EditorPathSettingName, riderPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,17 +50,15 @@ namespace GodotTools.Ides.Rider
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var newPath = paths.Last().Path;
|
var newPath = paths.Last().Path;
|
||||||
Globals.EditorDef(editorPathSettingName, newPath);
|
Globals.EditorDef(EditorPathSettingName, newPath);
|
||||||
editorSettings.SetSetting(editorPathSettingName, newPath);
|
editorSettings.SetSetting(EditorPathSettingName, newPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsRider(string path)
|
public static bool IsRider(string path)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
var fileInfo = new FileInfo(path);
|
var fileInfo = new FileInfo(path);
|
||||||
var filename = fileInfo.Name.ToLowerInvariant();
|
var filename = fileInfo.Name.ToLowerInvariant();
|
||||||
|
@ -81,8 +79,8 @@ namespace GodotTools.Ides.Rider
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var newPath = paths.Last().Path;
|
var newPath = paths.Last().Path;
|
||||||
editorSettings.SetSetting(editorPathSettingName, newPath);
|
editorSettings.SetSetting(EditorPathSettingName, newPath);
|
||||||
Globals.EditorDef(editorPathSettingName, newPath);
|
Globals.EditorDef(EditorPathSettingName, newPath);
|
||||||
return newPath;
|
return newPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue