-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
68 lines (53 loc) · 2.04 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using CmdShellProj;
using System;
using System.Text;
namespace ConsoleRunner
{
class Program
{
static void Main(string[] args)
{
var msBuildCommandPrompt = @"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsMSBuildCmd.bat";
var somePath = @"C:\temp";
var cmdCommands = $@"
CD /
none_existing_command /oops
ping example.com -n 2
none_existing_command /oops
CALL ""{msBuildCommandPrompt}""
CD ""{somePath}""
CALL MsBuild SomeProject.csproj^
/target:Build^
/p:Configuration=Release^
/verbosity:normal^
/maxCpuCount
ECHO ErrorLever = %ERRORLEVEL%";
var exitCode1 = new CmdShell()
.ExecAndShowCatched(cmdCommands);
StringBuilder output;
var exitCode1_2 = new CmdShell()
.ExecAndShowCatched(cmdCommands, out output);
var exitCode2 = new CmdShell()
.ExecAndShow(cmdCommands);
var exitCode3 = new CmdShell()
.ExecExample(cmdCommands);
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("exit code is {0} for ExecAndShowCatched", exitCode1);
Console.WriteLine("exit code is {0} for ExecAndShowCatched with outputs", exitCode1_2);
Console.WriteLine("exit code is {0} for ExecAndShow", exitCode2);
Console.WriteLine("exit code is {0} for ExecExample", exitCode3);
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("========================================================");
Console.WriteLine("Click to show intercepted outputs for ExecAndShowCatched");
Console.WriteLine("========================================================");
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.ReadKey();
Console.WriteLine(output);
}
}
}