diff options
Diffstat (limited to 'src/WixToolset.Core/AppCommon.cs')
-rw-r--r-- | src/WixToolset.Core/AppCommon.cs | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/src/WixToolset.Core/AppCommon.cs b/src/WixToolset.Core/AppCommon.cs index 7716155a..3ea09f08 100644 --- a/src/WixToolset.Core/AppCommon.cs +++ b/src/WixToolset.Core/AppCommon.cs | |||
@@ -3,13 +3,7 @@ | |||
3 | namespace WixToolset.Core | 3 | namespace WixToolset.Core |
4 | { | 4 | { |
5 | using System; | 5 | using System; |
6 | using System.Collections.Specialized; | ||
7 | using System.Globalization; | ||
8 | using System.IO; | ||
9 | using System.Reflection; | 6 | using System.Reflection; |
10 | using System.Text; | ||
11 | using System.Threading; | ||
12 | using WixToolset.Data; | ||
13 | 7 | ||
14 | /// <summary> | 8 | /// <summary> |
15 | /// Common utilities for Wix applications. | 9 | /// Common utilities for Wix applications. |
@@ -17,102 +11,6 @@ namespace WixToolset.Core | |||
17 | public static class AppCommon | 11 | public static class AppCommon |
18 | { | 12 | { |
19 | /// <summary> | 13 | /// <summary> |
20 | /// Read the configuration file (*.exe.config). | ||
21 | /// </summary> | ||
22 | /// <param name="extensions">Extensions to load.</param> | ||
23 | public static void ReadConfiguration(StringCollection extensions) | ||
24 | { | ||
25 | if (null == extensions) | ||
26 | { | ||
27 | throw new ArgumentNullException("extensions"); | ||
28 | } | ||
29 | |||
30 | #if REDO_IN_NETCORE | ||
31 | // Don't use the default AppSettings reader because | ||
32 | // the tool may be called from within another process. | ||
33 | // Instead, read the .exe.config file from the tool location. | ||
34 | string toolPath = (new System.Uri(Assembly.GetCallingAssembly().CodeBase)).LocalPath; | ||
35 | Configuration config = ConfigurationManager.OpenExeConfiguration(toolPath); | ||
36 | if (config.HasFile) | ||
37 | { | ||
38 | KeyValueConfigurationElement configVal = config.AppSettings.Settings["extensions"]; | ||
39 | if (configVal != null) | ||
40 | { | ||
41 | string extensionTypes = configVal.Value; | ||
42 | foreach (string extensionType in extensionTypes.Split(";".ToCharArray())) | ||
43 | { | ||
44 | extensions.Add(extensionType); | ||
45 | } | ||
46 | } | ||
47 | } | ||
48 | #endif | ||
49 | } | ||
50 | |||
51 | /// <summary> | ||
52 | /// Gets a unique temporary location or uses the provided temporary location. | ||
53 | /// </summary> | ||
54 | /// <param name="tempLocation">Optional temporary location to use.</param> | ||
55 | /// <returns>Temporary location.</returns> | ||
56 | public static string GetTempLocation(string tempLocation = null) | ||
57 | { | ||
58 | if (String.IsNullOrEmpty(tempLocation)) | ||
59 | { | ||
60 | tempLocation = Environment.GetEnvironmentVariable("WIX_TEMP") ?? Path.GetTempPath(); | ||
61 | |||
62 | do | ||
63 | { | ||
64 | tempLocation = Path.Combine(tempLocation, DateTime.Now.ToString("wixyyMMddTHHmmssffff")); | ||
65 | } while (Directory.Exists(tempLocation)); | ||
66 | } | ||
67 | |||
68 | return tempLocation; | ||
69 | } | ||
70 | |||
71 | /// <summary> | ||
72 | /// Delete a directory with retries and best-effort cleanup. | ||
73 | /// </summary> | ||
74 | /// <param name="path">The directory to delete.</param> | ||
75 | /// <param name="messageHandler">The message handler.</param> | ||
76 | /// <returns>True if all files were deleted, false otherwise.</returns> | ||
77 | public static bool DeleteDirectory(string path, IMessageHandler messageHandler) | ||
78 | { | ||
79 | return Common.DeleteTempFiles(path, messageHandler); | ||
80 | } | ||
81 | |||
82 | /// <summary> | ||
83 | /// Prepares the console for localization. | ||
84 | /// </summary> | ||
85 | public static void PrepareConsoleForLocalization() | ||
86 | { | ||
87 | Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture.GetConsoleFallbackUICulture(); | ||
88 | if ((Console.OutputEncoding.CodePage != Encoding.UTF8.CodePage) && | ||
89 | (Console.OutputEncoding.CodePage != Thread.CurrentThread.CurrentUICulture.TextInfo.OEMCodePage) && | ||
90 | (Console.OutputEncoding.CodePage != Thread.CurrentThread.CurrentUICulture.TextInfo.ANSICodePage)) | ||
91 | { | ||
92 | Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | /// <summary> | ||
97 | /// Handler for display message events. | ||
98 | /// </summary> | ||
99 | /// <param name="sender">Sender of message.</param> | ||
100 | /// <param name="e">Event arguments containing message to display.</param> | ||
101 | public static void ConsoleDisplayMessage(object sender, DisplayEventArgs e) | ||
102 | { | ||
103 | switch (e.Level) | ||
104 | { | ||
105 | case MessageLevel.Warning: | ||
106 | case MessageLevel.Error: | ||
107 | Console.Error.WriteLine(e.Message); | ||
108 | break; | ||
109 | default: | ||
110 | Console.WriteLine(e.Message); | ||
111 | break; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | /// <summary> | ||
116 | /// Creates and returns the string for CreatingApplication field (MSI Summary Information Stream). | 14 | /// Creates and returns the string for CreatingApplication field (MSI Summary Information Stream). |
117 | /// </summary> | 15 | /// </summary> |
118 | /// <remarks>It reads the AssemblyProductAttribute and AssemblyVersionAttribute of executing assembly | 16 | /// <remarks>It reads the AssemblyProductAttribute and AssemblyVersionAttribute of executing assembly |