Files
One_click_run_wpf/scripts/smoke.ps1
T

47 lines
1.7 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 一键运行 - 启动冒烟验证脚本(PowerShell 7.6.5
$ErrorActionPreference = 'Stop'
$exe = 'E:\002_Demo\One_click_run_wpf\src\OneClickRun\bin\Debug\net8.0-windows\OneClickRun.exe'
if (-not (Test-Path $exe)) { throw "未找到构建产物: $exe" }
# 清理上次冒烟残留(仅本路径实例)
Get-Process -Name 'OneClickRun' -ErrorAction SilentlyContinue |
Where-Object { $_.Path -eq $exe } |
ForEach-Object { Stop-Process -Id $_.Id -Force }
$logFile = Join-Path $env:APPDATA 'OneClickRun\logs\app-{0}.log' -f (Get-Date -Format 'yyyyMMdd')
$logBefore = 0
if (Test-Path $logFile) { $logBefore = (Get-Item $logFile).Length }
$p = Start-Process -FilePath $exe -PassThru
Start-Sleep -Seconds 6
$p.Refresh()
$alive = -not $p.HasExited
Write-Output "ProcessAlive: $alive"
$cfg = Join-Path $env:APPDATA 'OneClickRun\config.json'
Write-Output "ConfigExists: $(Test-Path $cfg)"
if (Test-Path $cfg) {
$json = Get-Content $cfg -Raw | ConvertFrom-Json
Write-Output "ConfigItems: $($json.items.Count)"
Write-Output "HotkeyText: $($json.general.hotkey.modifiers -join '+')+$($json.general.hotkey.key)"
Write-Output "TriggerMode: $($json.general.triggerMode)"
Write-Output "SelectionMode: $($json.general.selectionMode)"
Write-Output "Theme: $($json.general.theme)"
}
Write-Output '--- 本次启动新增日志 ---'
if (Test-Path $logFile) {
$stream = [System.IO.File]::Open($logFile, 'Open', 'Read', 'ReadWrite')
$reader = New-Object System.IO.StreamReader($stream)
$reader.BaseStream.Seek($logBefore, 'Begin') | Out-Null
$delta = $reader.ReadToEnd()
$reader.Close(); $stream.Close()
Write-Output $delta
}
if ($alive) {
Stop-Process -Id $p.Id -Force
Write-Output 'ProcessStopped: true'
}
Write-Output 'SmokeDone'