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 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);