Make console opening Windows + Debug only

This commit is contained in:
Matt Nadareski
2021-06-29 13:49:37 -07:00
parent 258b3e9fee
commit ef7cdcb2e1
2 changed files with 8 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
#if Windows #if WindowsDebug
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
#endif #endif
using Avalonia; using Avalonia;
@@ -10,17 +10,17 @@ namespace RedBookPlayer
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
#if Windows #if WindowsDebug
AllocConsole(); AllocConsole();
#endif #endif
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
} }
#if Windows #if WindowsDebug
[DllImport("kernel32.dll", SetLastError = true)] [DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole(); static extern bool AllocConsole();
#endif #endif
public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure<App>().UsePlatformDetect().LogToDebug(); public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure<App>().UsePlatformDetect().LogToDebug();
} }

View File

@@ -1,17 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers> <RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<DebugType>embedded</DebugType> <DebugType>embedded</DebugType>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<PublishTrimmed>true</PublishTrimmed>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x64' AND '$(Configuration)' == 'Debug'">
<DefineConstants>Windows</DefineConstants> <DefineConstants>WindowsDebug</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Update="**\*.xaml.cs"> <Compile Update="**\*.xaml.cs">