Esempio n. 1
0
        private void _MakeApiSolutionsIfNeededImpl()
        {
            // If the project has a solution and C# project make sure the API assemblies are present and up to date

            string api_config       = "Debug";
            string resAssembliesDir = Path.Combine(GodotSharpDirs.ResAssembliesBaseDir, api_config);

            if (!File.Exists(Path.Combine(resAssembliesDir, $"{ApiAssemblyNames.Core}.dll")) ||
                Internal.MetadataIsApiAssemblyInvalidated(ApiAssemblyType.Core))
            {
                if (!GodotSharpBuilds.MakeApiAssembly(ApiAssemblyType.Core, api_config))
                {
                    return;
                }
            }

            if (!File.Exists(Path.Combine(resAssembliesDir, $"{ApiAssemblyNames.Editor}.dll")) ||
                Internal.MetadataIsApiAssemblyInvalidated(ApiAssemblyType.Editor))
            {
                if (!GodotSharpBuilds.MakeApiAssembly(ApiAssemblyType.Editor, api_config))
                {
                    return; // Redundant? I don't think so!
                }
            }
        }
Esempio n. 2
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);
            }
        }