private bool CreateProjectSolution()
        {
            using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 2))
            {
                pr.Step("Generating C# project...".TTR());

                string resourceDir = ProjectSettings.GlobalizePath("res://");

                string path = resourceDir;
                string name = GodotSharpDirs.ProjectAssemblyName;

                string guid = CsProjOperations.GenerateGameProject(path, name);

                if (guid.Length > 0)
                {
                    var solution = new DotNetSolution(name)
                    {
                        DirectoryPath = path
                    };

                    var projectInfo = new DotNetSolution.ProjectInfo
                    {
                        Guid = guid,
                        PathRelativeToSolution = name + ".csproj",
                        Configs = new List <string> {
                            "Debug", "ExportDebug", "ExportRelease"
                        }
                    };

                    solution.AddNewProject(name, projectInfo);

                    try
                    {
                        solution.Save();
                    }
                    catch (IOException e)
                    {
                        ShowErrorDialog("Failed to save solution. Exception message: ".TTR() + e.Message);
                        return(false);
                    }

                    pr.Step("Done".TTR());

                    // Here, after all calls to progress_task_step
                    CallDeferred(nameof(_RemoveCreateSlnMenuOption));
                }
                else
                {
                    ShowErrorDialog("Failed to create C# project.".TTR());
                }

                return(true);
            }
        }
Beispiel #2
0
        public static void GenerateApiSolution(string solutionDir,
                                               string coreProjDir, IEnumerable <string> coreCompileItems,
                                               string editorProjDir, IEnumerable <string> editorCompileItems)
        {
            var solution = new DotNetSolution(ApiAssemblyNames.SolutionName);

            solution.DirectoryPath = solutionDir;

            // GodotSharp project

            const string coreApiAssemblyName = ApiAssemblyNames.Core;

            string coreGuid = ProjectGenerator.GenCoreApiProject(coreProjDir, coreCompileItems);

            var coreProjInfo = new DotNetSolution.ProjectInfo
            {
                Guid = coreGuid,
                PathRelativeToSolution = Path.Combine(coreApiAssemblyName, $"{coreApiAssemblyName}.csproj")
            };

            coreProjInfo.Configs.Add("Debug");
            coreProjInfo.Configs.Add("Release");

            solution.AddNewProject(coreApiAssemblyName, coreProjInfo);

            // GodotSharpEditor project

            const string editorApiAssemblyName = ApiAssemblyNames.Editor;

            string editorGuid = ProjectGenerator.GenEditorApiProject(editorProjDir,
                                                                     $"../{coreApiAssemblyName}/{coreApiAssemblyName}.csproj", editorCompileItems);

            var editorProjInfo = new DotNetSolution.ProjectInfo();

            editorProjInfo.Guid = editorGuid;
            editorProjInfo.PathRelativeToSolution = Path.Combine(editorApiAssemblyName, $"{editorApiAssemblyName}.csproj");
            editorProjInfo.Configs.Add("Debug");
            editorProjInfo.Configs.Add("Release");

            solution.AddNewProject(editorApiAssemblyName, editorProjInfo);

            // Save solution

            solution.Save();
        }
Beispiel #3
0
        private bool CreateProjectSolution()
        {
            using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 3))
            {
                pr.Step("Generating C# project...".TTR());

                string resourceDir = ProjectSettings.GlobalizePath("res://");

                string path = resourceDir;
                string name = (string)ProjectSettings.GetSetting("application/config/name");
                if (name.Empty())
                {
                    name = "UnnamedProject";
                }

                string guid = CsProjOperations.GenerateGameProject(path, name);

                if (guid.Length > 0)
                {
                    var solution = new DotNetSolution(name)
                    {
                        DirectoryPath = path
                    };

                    var projectInfo = new DotNetSolution.ProjectInfo
                    {
                        Guid = guid,
                        PathRelativeToSolution = name + ".csproj",
                        Configs = new List <string> {
                            "Debug", "Release", "Tools"
                        }
                    };

                    solution.AddNewProject(name, projectInfo);

                    try
                    {
                        solution.Save();
                    }
                    catch (IOException e)
                    {
                        ShowErrorDialog("Failed to save solution. Exception message: ".TTR() + e.Message);
                        return(false);
                    }

                    pr.Step("Updating Godot API assemblies...".TTR());

                    string debugApiAssembliesError = Internal.UpdateApiAssembliesFromPrebuilt("Debug");

                    if (!string.IsNullOrEmpty(debugApiAssembliesError))
                    {
                        ShowErrorDialog("Failed to update the Godot API assemblies: " + debugApiAssembliesError);
                        return(false);
                    }

                    string releaseApiAssembliesError = Internal.UpdateApiAssembliesFromPrebuilt("Release");

                    if (!string.IsNullOrEmpty(releaseApiAssembliesError))
                    {
                        ShowErrorDialog("Failed to update the Godot API assemblies: " + releaseApiAssembliesError);
                        return(false);
                    }

                    pr.Step("Done".TTR());

                    // Here, after all calls to progress_task_step
                    CallDeferred(nameof(_RemoveCreateSlnMenuOption));
                }
                else
                {
                    ShowErrorDialog("Failed to create C# project.".TTR());
                }

                return(true);
            }
        }
Beispiel #4
0
        private bool CreateProjectSolution()
        {
            using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 2))
            {
                pr.Step("Generating C# project...".TTR());

                string resourceDir = ProjectSettings.GlobalizePath("res://");

                string path = resourceDir;
                string name = (string)ProjectSettings.GetSetting("application/config/name");
                if (name.Empty())
                {
                    name = "UnnamedProject";
                }

                string guid = CSharpProject.GenerateGameProject(path, name);

                if (guid.Length > 0)
                {
                    var solution = new DotNetSolution(name)
                    {
                        DirectoryPath = path
                    };

                    var projectInfo = new DotNetSolution.ProjectInfo
                    {
                        Guid = guid,
                        PathRelativeToSolution = name + ".csproj",
                        Configs = new List <string> {
                            "Debug", "Release", "Tools"
                        }
                    };

                    solution.AddNewProject(name, projectInfo);

                    try
                    {
                        solution.Save();
                    }
                    catch (IOException e)
                    {
                        ShowErrorDialog("Failed to save solution. Exception message: ".TTR() + e.Message);
                        return(false);
                    }

                    // Make sure to update the API assemblies if they happen to be missing. Just in
                    // case the user decided to delete them at some point after they were loaded.
                    Internal.UpdateApiAssembliesFromPrebuilt();

                    pr.Step("Done".TTR());

                    // Here, after all calls to progress_task_step
                    CallDeferred(nameof(_RemoveCreateSlnMenuOption));
                }
                else
                {
                    ShowErrorDialog("Failed to create C# project.".TTR());
                }

                return(true);
            }
        }
Beispiel #5
0
        private bool CreateProjectSolution()
        {
            using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...", 2)) // TTR("Generating solution...")
            {
                pr.Step("Generating C# project...");                                                   // TTR("Generating C# project...")

                string resourceDir = ProjectSettings.GlobalizePath("res://");

                string path = resourceDir;
                string name = (string)ProjectSettings.GetSetting("application/config/name");
                if (name.Empty())
                {
                    name = "UnnamedProject";
                }

                string guid = CSharpProject.GenerateGameProject(path, name);

                if (guid.Length > 0)
                {
                    var solution = new DotNetSolution(name)
                    {
                        DirectoryPath = path
                    };

                    var projectInfo = new DotNetSolution.ProjectInfo
                    {
                        Guid = guid,
                        PathRelativeToSolution = name + ".csproj",
                        Configs = new List <string> {
                            "Debug", "Release", "Tools"
                        }
                    };

                    solution.AddNewProject(name, projectInfo);

                    try
                    {
                        solution.Save();
                    }
                    catch (IOException e)
                    {
                        ShowErrorDialog($"Failed to save solution. Exception message: {e.Message}"); // TTR
                        return(false);
                    }

                    string apiConfig = "Debug";

                    if (!GodotSharpBuilds.MakeApiAssembly(ApiAssemblyType.Core, apiConfig))
                    {
                        return(false);
                    }

                    if (!GodotSharpBuilds.MakeApiAssembly(ApiAssemblyType.Editor, apiConfig))
                    {
                        return(false);
                    }

                    pr.Step("Done"); // TTR("Done")

                    // Here, after all calls to progress_task_step
                    CallDeferred(nameof(_RemoveCreateSlnMenuOption));
                }
                else
                {
                    ShowErrorDialog("Failed to create C# project."); // TTR
                }

                return(true);
            }
        }