Add headless macOS CLI workflow
This commit is contained in:
@@ -1,6 +1,21 @@
|
||||
#region Console functions
|
||||
|
||||
function Test-IsWindowsPlatform
|
||||
{
|
||||
return ([Environment]::OSVersion.Platform -eq [System.PlatformID]::Win32NT)
|
||||
}
|
||||
|
||||
function Invoke-AppDoEvents
|
||||
{
|
||||
if("System.Windows.Forms.Application" -as [type])
|
||||
{
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
}
|
||||
|
||||
# https://stackoverflow.com/questions/40617800/opening-powershell-script-and-hide-command-prompt-but-not-the-gui
|
||||
if(Test-IsWindowsPlatform)
|
||||
{
|
||||
Add-Type -Name Window -Namespace Console -MemberDefinition '
|
||||
[DllImport("Kernel32.dll")]
|
||||
public static extern IntPtr GetConsoleWindow();
|
||||
@@ -17,9 +32,11 @@ public static extern bool SetConsoleIcon(IntPtr hIcon);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int SendMessage(int hWnd, uint wMsg, uint wParam, IntPtr lParam);
|
||||
'
|
||||
}
|
||||
|
||||
function Show-Console
|
||||
{
|
||||
if(-not (Test-IsWindowsPlatform)) { return }
|
||||
$consolePtr = [Console.Window]::GetConsoleWindow()
|
||||
|
||||
# Hide = 0,
|
||||
@@ -41,6 +58,7 @@ function Show-Console
|
||||
|
||||
function Hide-Console
|
||||
{
|
||||
if(-not (Test-IsWindowsPlatform)) { return }
|
||||
$consolePtr = [Console.Window]::GetConsoleWindow()
|
||||
#0 hide
|
||||
[Console.Window]::ShowWindow($consolePtr, 0) | Out-Null
|
||||
@@ -94,17 +112,19 @@ function Initialize-CloudAPIManagement
|
||||
)
|
||||
|
||||
$PSModuleAutoloadingPreference = "none"
|
||||
$global:hideUI = ($Silent -eq $true)
|
||||
$global:SilentBatchFile = $SilentBatchFile
|
||||
|
||||
$global:wpfNS = "xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'"
|
||||
|
||||
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
|
||||
Add-Type -AssemblyName PresentationFramework
|
||||
if($global:hideUI -ne $true)
|
||||
{
|
||||
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
|
||||
Add-Type -AssemblyName PresentationFramework
|
||||
}
|
||||
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
$global:hideUI = ($Silent -eq $true)
|
||||
$global:SilentBatchFile = $SilentBatchFile
|
||||
|
||||
if($tenantId)
|
||||
{
|
||||
Write-Host "Using Tenant Id: $tenantId"
|
||||
@@ -163,7 +183,7 @@ function Initialize-CloudAPIManagement
|
||||
$global:txtSplashTitle.Text = ("Initializing Cloud API PowerShell Management")
|
||||
|
||||
$global:SplashScreen.Show() | Out-Null
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
Invoke-AppDoEvents
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -204,15 +224,15 @@ function Initialize-CloudAPIManagement
|
||||
{
|
||||
$global:txtSplashText.Text = "Unblock files"
|
||||
}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
Invoke-AppDoEvents
|
||||
Unblock-AllFiles $PSScriptRoot
|
||||
|
||||
if($global:hideUI -ne $true)
|
||||
{
|
||||
$global:txtSplashText.Text = "Load core module"
|
||||
}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
Import-Module ($PSScriptRoot + "\Core.psm1") -Force -Global
|
||||
Invoke-AppDoEvents
|
||||
Import-Module (Join-Path $PSScriptRoot "Core.psm1") -Force -Global
|
||||
|
||||
Start-CoreApp $View
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user