private static MSBuildInfo GetMSBuildInfo()
        {
            MSBuildInfo msbuildInfo = new MSBuildInfo();

            godot_icall_BuildInstance_get_MSBuildInfo(ref msbuildInfo.path, ref msbuildInfo.frameworkPathOverride);

            if (msbuildInfo.path == null)
            {
                throw new FileNotFoundException("Cannot find the MSBuild executable.");
            }

            return(msbuildInfo);
        }
        public bool BuildAsync(string loggerAssemblyPath, string loggerOutputDir, string[] customProperties = null)
        {
            if (process != null)
            {
                throw new InvalidOperationException("Already in use");
            }

            MSBuildInfo msbuildInfo = GetMSBuildInfo();

            List <string> customPropertiesList = new List <string>();

            if (customProperties != null)
            {
                customPropertiesList.AddRange(customProperties);
            }

            if (msbuildInfo.frameworkPathOverride.Length > 0)
            {
                customPropertiesList.Add("FrameworkPathOverride=" + msbuildInfo.frameworkPathOverride);
            }

            string compilerArgs = BuildArguments(loggerAssemblyPath, loggerOutputDir, customPropertiesList);

            ProcessStartInfo startInfo = new ProcessStartInfo(msbuildInfo.path, compilerArgs);

            // No console output, thanks
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError  = true;
            startInfo.UseShellExecute        = false;

            // Needed when running from Developer Command Prompt for VS
            RemovePlatformVariable(startInfo.EnvironmentVariables);

            process                     = new Process();
            process.StartInfo           = startInfo;
            process.EnableRaisingEvents = true;
            process.Exited             += new EventHandler(BuildProcess_Exited);

            process.Start();

            process.BeginOutputReadLine();
            process.BeginErrorReadLine();

            return(true);
        }
        public bool Build(string loggerAssemblyPath, string loggerOutputDir, string[] customProperties = null)
        {
            MSBuildInfo msbuildInfo = GetMSBuildInfo();

            List <string> customPropertiesList = new List <string>();

            if (customProperties != null)
            {
                customPropertiesList.AddRange(customProperties);
            }

            if (msbuildInfo.frameworkPathOverride != null)
            {
                customPropertiesList.Add("FrameworkPathOverride=" + msbuildInfo.frameworkPathOverride);
            }

            string compilerArgs = BuildArguments(loggerAssemblyPath, loggerOutputDir, customPropertiesList);

            ProcessStartInfo startInfo = new ProcessStartInfo(msbuildInfo.path, compilerArgs);

            // No console output, thanks
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError  = true;
            startInfo.UseShellExecute        = false;

            // Needed when running from Developer Command Prompt for VS
            RemovePlatformVariable(startInfo.EnvironmentVariables);

            using (Process process = new Process())
            {
                process.StartInfo = startInfo;

                process.Start();

                process.BeginOutputReadLine();
                process.BeginErrorReadLine();

                process.WaitForExit();

                exitCode = process.ExitCode;
            }

            return(true);
        }