From 41979979f74e030a1bd21a84bc606106ab65e856 Mon Sep 17 00:00:00 2001 From: ArgusMagnus Date: Fri, 29 Apr 2022 13:28:08 +0200 Subject: [PATCH 1/2] Update main.yml dotnet-version: '6.0.x' --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c3c934a..29a1116 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core SDK uses: actions/setup-dotnet@v1 with: - dotnet-version: '5.0.x' + dotnet-version: '6.0.x' - name: Build run: dotnet build -c Release @@ -27,14 +27,14 @@ jobs: - name: Setup .NET Core SDK uses: actions/setup-dotnet@v1 with: - dotnet-version: '5.0.x' + dotnet-version: '6.0.x' - name: Build run: | $version = "${{ github.ref }}" $version = $version.Substring(10) Add-Content -Path $env:GITHUB_ENV -Value "RELEASE_TAG=$version" -Encoding UTF8 - dotnet publish -c Release -r win-x86 -o ./publish/win/x86 -p:ReleaseTag=$version - dotnet publish -c Release -r win-x64 -o ./publish/win/x64 -p:ReleaseTag=$version + dotnet publish -c Release -r win-x86 -o ./publish/win/x86 -p:ReleaseTag=$version --self-contained + dotnet publish -c Release -r win-x64 -o ./publish/win/x64 -p:ReleaseTag=$version --self-contained Compress-Archive -Path ./publish/win/* -DestinationPath ./publish/win.zip -CompressionLevel Optimal - name: Create Release id: create_release From 471af37cf1e842fd82ead79f5899ee32ef2eca40 Mon Sep 17 00:00:00 2001 From: ArgusMagnus Date: Fri, 8 Jul 2022 16:18:28 +0200 Subject: [PATCH 2/2] update templates --- Templates/Script.csx | 12 ++++++++++++ Templates/ScriptUI.csx | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Templates/Script.csx b/Templates/Script.csx index 5f8620a..deea2fe 100644 --- a/Templates/Script.csx +++ b/Templates/Script.csx @@ -46,6 +46,18 @@ static class Script static readonly IntPtr _consoleWindow = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; + [System.Runtime.InteropServices.DllImport("user32.dll")] + static extern int GetWindowThreadProcessId(IntPtr hWnd, out int processId); + + static bool GetIsConsoleOwner() + { + int processId; + GetWindowThreadProcessId(_consoleWindow, out processId); + return processId == System.Diagnostics.Process.GetCurrentProcess().Id; + } + + public static bool IsConsoleOwner { get; } = GetIsConsoleOwner(); + [System.Runtime.InteropServices.DllImport("user32.dll")] static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); diff --git a/Templates/ScriptUI.csx b/Templates/ScriptUI.csx index b4c8ff2..42c2091 100644 --- a/Templates/ScriptUI.csx +++ b/Templates/ScriptUI.csx @@ -69,6 +69,18 @@ static class Script static readonly IntPtr _consoleWindow = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; + [System.Runtime.InteropServices.DllImport("user32.dll")] + static extern int GetWindowThreadProcessId(IntPtr hWnd, out int processId); + + static bool GetIsConsoleOwner() + { + int processId; + GetWindowThreadProcessId(_consoleWindow, out processId); + return processId == System.Diagnostics.Process.GetCurrentProcess().Id; + } + + public static bool IsConsoleOwner { get; } = GetIsConsoleOwner(); + [System.Runtime.InteropServices.DllImport("user32.dll")] static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);