diff options
Diffstat (limited to 'src/samples/burn/runbundle/Program.cs')
-rw-r--r-- | src/samples/burn/runbundle/Program.cs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/samples/burn/runbundle/Program.cs b/src/samples/burn/runbundle/Program.cs new file mode 100644 index 00000000..8edca5dc --- /dev/null +++ b/src/samples/burn/runbundle/Program.cs | |||
@@ -0,0 +1,47 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace Wix.Samples | ||
4 | { | ||
5 | using System; | ||
6 | using System.Linq; | ||
7 | using Wix.Samples; | ||
8 | |||
9 | /// <summary> | ||
10 | /// Example executable that installs then immediately uninstalls a bundle showing progress. | ||
11 | /// </summary> | ||
12 | class Program | ||
13 | { | ||
14 | static int Main(string[] args) | ||
15 | { | ||
16 | if (args.Length == 0) | ||
17 | { | ||
18 | Console.WriteLine("Must provide the path to the bundle to install then uninstall."); | ||
19 | return -1; | ||
20 | } | ||
21 | |||
22 | BundleRunner runner = new BundleRunner(args[0]); | ||
23 | runner.Error += Program.OnError; | ||
24 | runner.Progress += Program.OnProgress; | ||
25 | |||
26 | Console.WriteLine("Installing: {0}", runner.Path); | ||
27 | int exitCode = runner.Run(String.Join(" ", args.Skip(1).ToArray())); | ||
28 | if (0 == exitCode) | ||
29 | { | ||
30 | Console.WriteLine("\r\nUninstalling: {0}", runner.Path); | ||
31 | exitCode = runner.Run("-uninstall"); | ||
32 | } | ||
33 | |||
34 | return exitCode; | ||
35 | } | ||
36 | |||
37 | static void OnError(object sender, BundleErrorEventArgs e) | ||
38 | { | ||
39 | Console.WriteLine("error: {0}, uiHint: {1}, message: {2}", e.Code, e.UIHint, e.Message); | ||
40 | } | ||
41 | |||
42 | static void OnProgress(object sender, BundleProgressEventArgs e) | ||
43 | { | ||
44 | Console.WriteLine("progresss: {0}%", e.Progress); | ||
45 | } | ||
46 | } | ||
47 | } | ||