diff options
Diffstat (limited to 'src/WixToolset.Tools.Core')
| -rw-r--r-- | src/WixToolset.Tools.Core/ConsoleMessageListener.cs | 56 | ||||
| -rw-r--r-- | src/WixToolset.Tools.Core/WixToolset.Tools.Core.csproj | 28 |
2 files changed, 84 insertions, 0 deletions
diff --git a/src/WixToolset.Tools.Core/ConsoleMessageListener.cs b/src/WixToolset.Tools.Core/ConsoleMessageListener.cs new file mode 100644 index 00000000..5b1fb988 --- /dev/null +++ b/src/WixToolset.Tools.Core/ConsoleMessageListener.cs | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | using System; | ||
| 2 | using System.Globalization; | ||
| 3 | using System.Text; | ||
| 4 | using System.Threading; | ||
| 5 | using WixToolset.Data; | ||
| 6 | using WixToolset.Extensibility; | ||
| 7 | |||
| 8 | namespace WixToolset.Tools.Core | ||
| 9 | { | ||
| 10 | public sealed class ConsoleMessageListener : IMessageListener | ||
| 11 | { | ||
| 12 | public ConsoleMessageListener(string shortName, string longName) | ||
| 13 | { | ||
| 14 | this.ShortAppName = shortName; | ||
| 15 | this.LongAppName = longName; | ||
| 16 | |||
| 17 | PrepareConsoleForLocalization(); | ||
| 18 | } | ||
| 19 | |||
| 20 | public string LongAppName { get; } | ||
| 21 | |||
| 22 | public string ShortAppName { get; } | ||
| 23 | |||
| 24 | public void Write(Message message) | ||
| 25 | { | ||
| 26 | var filename = message.SourceLineNumbers?.FileName ?? this.LongAppName; | ||
| 27 | var line = message.SourceLineNumbers?.LineNumber ?? -1; | ||
| 28 | var type = message.Level.ToString().ToLowerInvariant(); | ||
| 29 | var output = message.Level >= MessageLevel.Warning ? Console.Out : Console.Error; | ||
| 30 | |||
| 31 | if (line > 0) | ||
| 32 | { | ||
| 33 | filename = String.Concat(filename, "(", line, ")"); | ||
| 34 | } | ||
| 35 | |||
| 36 | output.WriteLine("{0} : {1} {2}{3:0000}: {4}", filename, type, this.ShortAppName, message.Id, message.ToString()); | ||
| 37 | } | ||
| 38 | |||
| 39 | public void Write(string message) | ||
| 40 | { | ||
| 41 | Console.Out.WriteLine(message); | ||
| 42 | } | ||
| 43 | |||
| 44 | private static void PrepareConsoleForLocalization() | ||
| 45 | { | ||
| 46 | Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture.GetConsoleFallbackUICulture(); | ||
| 47 | |||
| 48 | if (Console.OutputEncoding.CodePage != Encoding.UTF8.CodePage && | ||
| 49 | Console.OutputEncoding.CodePage != Thread.CurrentThread.CurrentUICulture.TextInfo.OEMCodePage && | ||
| 50 | Console.OutputEncoding.CodePage != Thread.CurrentThread.CurrentUICulture.TextInfo.ANSICodePage) | ||
| 51 | { | ||
| 52 | Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | } | ||
| 56 | } | ||
diff --git a/src/WixToolset.Tools.Core/WixToolset.Tools.Core.csproj b/src/WixToolset.Tools.Core/WixToolset.Tools.Core.csproj new file mode 100644 index 00000000..8be70e6b --- /dev/null +++ b/src/WixToolset.Tools.Core/WixToolset.Tools.Core.csproj | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <!-- 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. --> | ||
| 3 | |||
| 4 | <Project Sdk="Microsoft.NET.Sdk"> | ||
| 5 | <PropertyGroup> | ||
| 6 | <TargetFramework>netstandard2.0</TargetFramework> | ||
| 7 | <Description>Tools Core</Description> | ||
| 8 | <Title>WiX Toolset Tools Core</Title> | ||
| 9 | <DebugType>embedded</DebugType> | ||
| 10 | <PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
| 11 | </PropertyGroup> | ||
| 12 | |||
| 13 | <ItemGroup> | ||
| 14 | <ProjectReference Include="$(WixToolsetRootFolder)\Data\src\WixToolset.Data\WixToolset.Data.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Data\README.md') " /> | ||
| 15 | <PackageReference Include="WixToolset.Data" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Data\README.md') " /> | ||
| 16 | |||
| 17 | <ProjectReference Include="$(WixToolsetRootFolder)\Extensibility\src\WixToolset.Extensibility\WixToolset.Extensibility.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Extensibility\README.md') " /> | ||
| 18 | <PackageReference Include="WixToolset.Extensibility" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Extensibility\README.md') " /> | ||
| 19 | |||
| 20 | <ProjectReference Include="$(WixToolsetRootFolder)\Core\src\WixToolset.Core\WixToolset.Core.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Core\README.md') " /> | ||
| 21 | <PackageReference Include="WixToolset.Core" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Core\README.md') " /> | ||
| 22 | </ItemGroup> | ||
| 23 | |||
| 24 | <ItemGroup> | ||
| 25 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63102-01" PrivateAssets="All"/> | ||
| 26 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" /> | ||
| 27 | </ItemGroup> | ||
| 28 | </Project> | ||
