From 61847dddd4fd497057c780658e383c4627de19ec Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 29 Dec 2018 22:12:08 -0600 Subject: Import code from old v4 repo --- src/Samples/runbundle/AssemblyInfo.cs | 12 +++++++++ src/Samples/runbundle/Program.cs | 47 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/Samples/runbundle/AssemblyInfo.cs create mode 100644 src/Samples/runbundle/Program.cs (limited to 'src/Samples/runbundle') diff --git a/src/Samples/runbundle/AssemblyInfo.cs b/src/Samples/runbundle/AssemblyInfo.cs new file mode 100644 index 00000000..3a66d5e3 --- /dev/null +++ b/src/Samples/runbundle/AssemblyInfo.cs @@ -0,0 +1,12 @@ +// 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. + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Executable to demonstrate Bundle Runner Sample")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyCulture("")] +[assembly: CLSCompliant(true)] +[assembly: ComVisible(false)] diff --git a/src/Samples/runbundle/Program.cs b/src/Samples/runbundle/Program.cs new file mode 100644 index 00000000..8edca5dc --- /dev/null +++ b/src/Samples/runbundle/Program.cs @@ -0,0 +1,47 @@ +// 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. + +namespace Wix.Samples +{ + using System; + using System.Linq; + using Wix.Samples; + + /// + /// Example executable that installs then immediately uninstalls a bundle showing progress. + /// + class Program + { + static int Main(string[] args) + { + if (args.Length == 0) + { + Console.WriteLine("Must provide the path to the bundle to install then uninstall."); + return -1; + } + + BundleRunner runner = new BundleRunner(args[0]); + runner.Error += Program.OnError; + runner.Progress += Program.OnProgress; + + Console.WriteLine("Installing: {0}", runner.Path); + int exitCode = runner.Run(String.Join(" ", args.Skip(1).ToArray())); + if (0 == exitCode) + { + Console.WriteLine("\r\nUninstalling: {0}", runner.Path); + exitCode = runner.Run("-uninstall"); + } + + return exitCode; + } + + static void OnError(object sender, BundleErrorEventArgs e) + { + Console.WriteLine("error: {0}, uiHint: {1}, message: {2}", e.Code, e.UIHint, e.Message); + } + + static void OnProgress(object sender, BundleProgressEventArgs e) + { + Console.WriteLine("progresss: {0}%", e.Progress); + } + } +} -- cgit v1.2.3-55-g6feb