コード例 #1
0
        /// <summary>
        /// Rebuild project after modifing
        /// </summary>
        /// <param name="inputProject"></param>
        /// <returns> path to .exe file </returns>
        private Tuple <string, LogProcess> RebuildProject(IProject inputProject)
        {
            CsprojFile csprojFile = Utils.SearchCsprojFile(inputProject.RootFolder);

            //rebuild project
            ProjectRebuilding projectRebuilding = new ProjectRebuilding();
            LogProcess        logBuilding       = projectRebuilding.Compile(csprojFile.Path);

            if (logBuilding.Output != null)
            {
                File.AppendAllText(@"..\..\Log Output\building.log", logBuilding.Output + NEW_LINE);
            }
            if (logBuilding.Error != null)
            {
                File.AppendAllText(@"..\..\Log Output\building.log", logBuilding.Error + NEW_LINE);
            }
            if (logBuilding.Error_count > 0 ||
                (logBuilding.Error != null && logBuilding.Error.Trim() != ""))
            {
                logger.Error("--Rebuild project fail: " + logBuilding.Error);
                return(new Tuple <string, LogProcess>(null, logBuilding));
            }

            string output = inputProject.RootFolder.Path + @"\bin\Debug";

            logger.Debug("Output path: " + output);
            ExeFile exeFile = FindExeFile(output);

            logger.Debug("Modified, Built successfully" + NEW_LINE +
                         "Get .exe file path: " + exeFile.Path);

            return(new Tuple <string, LogProcess>(exeFile.Path, logBuilding));
        }
コード例 #2
0
        public LogProcess ParseLogBuild(string log)
        {
            string     warning_pattern = @"(\d+)? Warning\(s\)";
            string     error_pattern   = @"(\d+)? Error\(s\)";
            LogProcess re        = new LogProcess();
            var        m_warning = Regex.Matches(log, warning_pattern);

            if (m_warning != null && m_warning.Count > 0)
            {
                re.Warning_count = Int32.Parse(m_warning[0].Groups[1].Value);
            }
            var m_error = Regex.Matches(log, error_pattern);

            if (m_error != null && m_error.Count > 0)
            {
                re.Error_count = Int32.Parse(m_error[0].Groups[1].Value);
            }
            return(re);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="projectFilePath"></param>
        /// <param name="msBuildToolPath"></param>
        /// <param name="nugetPath"></param>
        /// <returns></returns>
        public LogProcess Compile(string projectFilePath, string msBuildToolPath, string nugetPath)
        {
            msBuildToolPath = Utils.NormalizePathCmd(msBuildToolPath);
            nugetPath       = Utils.NormalizePathCmd(nugetPath);

            LogProcess logOut = new LogProcess();

            // restore nuget packages
            Process process = new Process();

            process.StartInfo.FileName = nugetPath;
            string temp = "restore \"" +
                          Path.Combine(Path.GetDirectoryName(projectFilePath), "packages.config") + "\"" +
                          " -PackagesDirectory \"" +
                          Path.Combine(Path.GetDirectoryName(projectFilePath), "..\\packages") + "\"";

            process.StartInfo.Arguments = temp;
            //logger.Debug("------" + temp);
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.Start();
            process.WaitForExit();
            //logger.Debug("----" + process.StandardOutput.ReadToEnd().Trim());

            // build project
            process = new Process();
            process.StartInfo.FileName               = msBuildToolPath;
            process.StartInfo.Arguments              = "\"" + projectFilePath + "\"";
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.Start();
            //* Read the output (or the error)
            string msg      = process.StandardOutput.ReadToEnd().Trim();
            string errorStr = process.StandardError.ReadToEnd().Trim();

            logOut = ParseLogBuild(msg);
            logOut.appendOutput(msg);
            logOut.appendError(errorStr);
            process.WaitForExit();
            return(logOut);
        }
コード例 #4
0
        public LogProcess Compile(string projectFilePath, string msBuildToolPath, string file2AppendLog, string nugetPath)
        {
            LogProcess logProcess = Compile(projectFilePath, msBuildToolPath, nugetPath);

            return(logProcess);
        }