Esempio n. 1
0
        /// <summary>
        /// Builds a game distribution from a project using the current compiler.
        /// </summary>
        /// <param name="project">The project to build.</param>
        /// <param name="debuggable">Whether the project should be built with debugging info.</param>
        /// <returns>The full path of the compiled distribution.</returns>
        public static async Task <string> Build(Project project, bool debuggable)
        {
            ICompiler compiler = PluginManager.Get <ICompiler>(project.Compiler);

            if (compiler == null)
            {
                MessageBox.Show(
                    string.Format("Unable to build '{0}'.\n\nA required plugin is missing.  You may not have the necessary compiler installed, or the plugin may be disabled.  Open Configuration Manager and check your plugins.\n\nCompiler required:\n{1}", project.Name, project.Compiler),
                    "Operation Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            _buildView.Clear();
            PluginManager.Core.Docking.Show(_buildView);
            PluginManager.Core.Docking.Activate(_buildView);

            _buildView.Print(string.Format("------------------- Build started: {0} -------------------\n", project.Name));
            string outPath = Path.Combine(project.RootPath, project.BuildPath);

            if (await compiler.Build(project, outPath, debuggable, _buildView))
            {
                _buildView.Print(string.Format("================= Successfully built: {0} ================", project.Name));
                return(outPath);
            }
            else
            {
                _buildView.Print(string.Format("================== Failed to build: {0} ==================", project.Name));
                SystemSounds.Exclamation.Play();
                return(null);
            }
        }