コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }