.NET Core on *nix doesn't like console

This commit is contained in:
Matt Nadareski
2020-06-11 10:22:00 -07:00
parent 4ad77d6be6
commit fc63217c56
4 changed files with 24 additions and 5 deletions

View File

@@ -8,6 +8,10 @@
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'!='netcoreapp3.1'">
<DefineConstants>NET_FRAMEWORK</DefineConstants>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Mono.Data.Sqlite.Portable" Version="1.0.3.5" /> <PackageReference Include="Mono.Data.Sqlite.Portable" Version="1.0.3.5" />
</ItemGroup> </ItemGroup>

View File

@@ -8,11 +8,18 @@ namespace SabreTools.Library.Data
public static class Build public static class Build
{ {
/// <summary> /// <summary>
/// Returns true if running in a Mono environment /// Returns true if running in a Mono or .NET Core environment
/// </summary> /// </summary>
public static bool MonoEnvironment public static bool MonoOrCoreEnvironment
{ {
get { return (Type.GetType("Mono.Runtime") != null); } get
{
#if NET_FRAMEWORK
return Type.GetType("Mono.Runtime") != null;
#else
return true;
#endif
}
} }
/// <summary> /// <summary>
@@ -33,7 +40,7 @@ namespace SabreTools.Library.Data
// Set the console to ready state // Set the console to ready state
ConsoleColor formertext = ConsoleColor.White; ConsoleColor formertext = ConsoleColor.White;
ConsoleColor formerback = ConsoleColor.Black; ConsoleColor formerback = ConsoleColor.Black;
if (!MonoEnvironment) if (!MonoOrCoreEnvironment)
{ {
Console.SetBufferSize(Console.BufferWidth, 999); Console.SetBufferSize(Console.BufferWidth, 999);
formertext = Console.ForegroundColor; formertext = Console.ForegroundColor;
@@ -51,7 +58,7 @@ namespace SabreTools.Library.Data
Console.WriteLine(); Console.WriteLine();
// Return the console to the original text and background colors // Return the console to the original text and background colors
if (!MonoEnvironment) if (!MonoOrCoreEnvironment)
{ {
Console.ForegroundColor = formertext; Console.ForegroundColor = formertext;
Console.BackgroundColor = formerback; Console.BackgroundColor = formerback;

View File

@@ -7,6 +7,10 @@
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'!='netcoreapp3.1'">
<DefineConstants>NET_FRAMEWORK</DefineConstants>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="Skippers\a7800.xml" /> <None Remove="Skippers\a7800.xml" />
<None Remove="Skippers\fds.xml" /> <None Remove="Skippers\fds.xml" />

View File

@@ -8,6 +8,10 @@
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'!='netcoreapp3.1'">
<DefineConstants>NET_FRAMEWORK</DefineConstants>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SabreTools.Library\SabreTools.Library.csproj" /> <ProjectReference Include="..\SabreTools.Library\SabreTools.Library.csproj" />
</ItemGroup> </ItemGroup>