Esempio n. 1
0
      public static async Task<bool> Execute(Params @params)
      {
         var arguments = string.Join(" ",
                                     string.Format("\"{0}\"", @params.SolutionPath),
                                     @params.Args,
                                     string.Format(MsBuildArgs,
                                                   @params.Configuration,
                                                   @params.Platform,
                                                   @params.Verbosity));
         var process = new Process
                       {
                          StartInfo = new ProcessStartInfo(MsBuildPath)
                                      {
                                         Arguments = arguments,
                                         CreateNoWindow = true,
                                         RedirectStandardOutput = true,
                                         UseShellExecute = false
                                      }
                       };
         process.OutputDataReceived += (sender, args) => @params.Callback(args.Data);
         process.Start();
         process.BeginOutputReadLine();
         while (!process.HasExited)
         {
            if (@params.CancellationToken.IsCancellationRequested)
            {
               process.Kill();
               return false;
            }

            await Task.Delay(50, @params.CancellationToken);
         }

         return process.ExitCode == 0;
      }