1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Check a csproj exists before trying to edit it

When folders are moved/removed from the file system, the `.csproj`
may need to be edited to update the path of C# scripts or remove them.
If a C# solution has not been created, the `.csproj` file does not exist
and therefore there is no need to edit it.

(cherry picked from commit cf98ff248a)
This commit is contained in:
Raul Santos
2021-12-20 16:49:16 +01:00
committed by Rémi Verschelde
parent b47fa3f348
commit 9520c6b953

View File

@@ -75,7 +75,7 @@ namespace GodotTools
{ {
Guid = guid, Guid = guid,
PathRelativeToSolution = name + ".csproj", PathRelativeToSolution = name + ".csproj",
Configs = new List<string> {"Debug", "ExportDebug", "ExportRelease"} Configs = new List<string> { "Debug", "ExportDebug", "ExportRelease" }
}; };
solution.AddNewProject(name, projectInfo); solution.AddNewProject(name, projectInfo);
@@ -164,20 +164,28 @@ namespace GodotTools
private void _FileSystemDockFileRemoved(string file) private void _FileSystemDockFileRemoved(string file)
{ {
if (Path.GetExtension(file) == Internal.CSharpLanguageExtension) if (Path.GetExtension(file) == Internal.CSharpLanguageExtension)
{
ProjectUtils.RemoveItemFromProjectChecked(GodotSharpDirs.ProjectCsProjPath, "Compile", ProjectUtils.RemoveItemFromProjectChecked(GodotSharpDirs.ProjectCsProjPath, "Compile",
ProjectSettings.GlobalizePath(file)); ProjectSettings.GlobalizePath(file));
}
} }
private void _FileSystemDockFolderMoved(string oldFolder, string newFolder) private void _FileSystemDockFolderMoved(string oldFolder, string newFolder)
{ {
ProjectUtils.RenameItemsToNewFolderInProjectChecked(GodotSharpDirs.ProjectCsProjPath, "Compile", if (File.Exists(GodotSharpDirs.ProjectCsProjPath))
ProjectSettings.GlobalizePath(oldFolder), ProjectSettings.GlobalizePath(newFolder)); {
ProjectUtils.RenameItemsToNewFolderInProjectChecked(GodotSharpDirs.ProjectCsProjPath, "Compile",
ProjectSettings.GlobalizePath(oldFolder), ProjectSettings.GlobalizePath(newFolder));
}
} }
private void _FileSystemDockFolderRemoved(string oldFolder) private void _FileSystemDockFolderRemoved(string oldFolder)
{ {
ProjectUtils.RemoveItemsInFolderFromProjectChecked(GodotSharpDirs.ProjectCsProjPath, "Compile", if (File.Exists(GodotSharpDirs.ProjectCsProjPath))
ProjectSettings.GlobalizePath(oldFolder)); {
ProjectUtils.RemoveItemsInFolderFromProjectChecked(GodotSharpDirs.ProjectCsProjPath, "Compile",
ProjectSettings.GlobalizePath(oldFolder));
}
} }
public override void _Ready() public override void _Ready()
@@ -431,7 +439,7 @@ namespace GodotTools
MSBuildPanel = new MSBuildPanel(); MSBuildPanel = new MSBuildPanel();
_bottomPanelBtn = AddControlToBottomPanel(MSBuildPanel, "MSBuild".TTR()); _bottomPanelBtn = AddControlToBottomPanel(MSBuildPanel, "MSBuild".TTR());
AddChild(new HotReloadAssemblyWatcher {Name = "HotReloadAssemblyWatcher"}); AddChild(new HotReloadAssemblyWatcher { Name = "HotReloadAssemblyWatcher" });
_menuPopup = new PopupMenu(); _menuPopup = new PopupMenu();
_menuPopup.Hide(); _menuPopup.Hide();