mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-08-09 17:41:14 +10:00
Clean up analyzer warnings across app search and ISO workflows (#4794)
* Clean up analyzer warnings * Align analyzer warning cleanup policy * Run PSScriptAnalyzer directly in unittests workflow * Bind lazy-rendered buttons to click handlers * Remove WinUtil performance tracing * Fix Win11 ISO creator temp directory reuse
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
function Write-Win11ISOLog {
|
||||
param([string]$Message)
|
||||
$ts = (Get-Date).ToString("HH:mm:ss")
|
||||
$logLine = "[$ts] $Message"
|
||||
$sync["WPFWin11ISOStatusLog"].Dispatcher.Invoke([action]{
|
||||
$current = $sync["WPFWin11ISOStatusLog"].Text
|
||||
if ($current -eq "Ready. Please select a Windows 11 ISO to begin.") {
|
||||
$sync["WPFWin11ISOStatusLog"].Text = "[$ts] $Message"
|
||||
$sync["WPFWin11ISOStatusLog"].Text = $logLine
|
||||
} else {
|
||||
$sync["WPFWin11ISOStatusLog"].Text += "`n[$ts] $Message"
|
||||
$sync["WPFWin11ISOStatusLog"].Text += "`n$logLine"
|
||||
}
|
||||
$sync["WPFWin11ISOStatusLog"].CaretIndex = $sync["WPFWin11ISOStatusLog"].Text.Length
|
||||
$sync["WPFWin11ISOStatusLog"].ScrollToEnd()
|
||||
@@ -151,14 +152,9 @@ function Invoke-WinUtilISOModify {
|
||||
$sync["WPFWin11ISOModifyButton"].IsEnabled = $false
|
||||
$sync["Win11ISOModifying"] = $true
|
||||
|
||||
$existingWorkDir = Get-Item -Path (Join-Path $env:TEMP "WinUtil_Win11ISO*") |
|
||||
Where-Object { $_.PSIsContainer } | Sort-Object LastWriteTime -Descending | Select-Object -First 1
|
||||
|
||||
$workDir = if ($existingWorkDir) {
|
||||
Write-Win11ISOLog "Reusing existing temp directory: $($existingWorkDir.FullName)"
|
||||
$existingWorkDir.FullName
|
||||
} else {
|
||||
Join-Path $env:TEMP "WinUtil_Win11ISO_$(Get-Date -Format 'yyyyMMdd_HHmmss')"
|
||||
$workDir = Join-Path $env:TEMP "WinUtil_Win11ISO_$(Get-Date -Format 'yyyyMMdd_HHmmss')"
|
||||
if (Test-Path $workDir) {
|
||||
$workDir = Join-Path $env:TEMP "WinUtil_Win11ISO_$(Get-Date -Format 'yyyyMMdd_HHmmss')_$(([guid]::NewGuid()).ToString('N').Substring(0, 8))"
|
||||
}
|
||||
|
||||
$autounattendContent = if ($WinUtilAutounattendXml) {
|
||||
@@ -293,9 +289,11 @@ function Invoke-WinUtilISOModify {
|
||||
[scriptblock]$Logger
|
||||
)
|
||||
|
||||
$metadataLogger = $Logger
|
||||
|
||||
function LogMeta([string]$Message) {
|
||||
if ($Logger) {
|
||||
$null = $Logger.Invoke($Message)
|
||||
if ($metadataLogger) {
|
||||
$null = $metadataLogger.Invoke($Message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,8 +366,11 @@ function Invoke-WinUtilISOModify {
|
||||
Log "ISO contents copied."
|
||||
SetProgress "Mounting install.wim..." 25
|
||||
|
||||
$localWim = Join-Path $isoContents "sources\install.wim"
|
||||
if (-not (Test-Path $localWim)) { $localWim = Join-Path $isoContents "sources\install.esd" }
|
||||
$sourceImageFileName = Split-Path $wimPath -Leaf
|
||||
$localWim = Join-Path $isoContents "sources\$sourceImageFileName"
|
||||
if (-not (Test-Path $localWim)) {
|
||||
throw "Copied ISO image file not found: sources\$sourceImageFileName"
|
||||
}
|
||||
Set-ItemProperty -Path $localWim -Name IsReadOnly -Value $false
|
||||
|
||||
Log "Mounting install.wim (Index ${selectedWimIndex}: $selectedEditionName) at $mountDir..."
|
||||
@@ -590,10 +591,10 @@ function Invoke-WinUtilISOCleanAndReset {
|
||||
}
|
||||
|
||||
foreach ($d in $allDirs) {
|
||||
try { Remove-Item -Path $d.FullName -Force } catch {}
|
||||
try { Remove-Item -Path $d.FullName -Force } catch { Log "WARNING: could not delete $($d.FullName): $_" }
|
||||
}
|
||||
|
||||
try { Remove-Item -Path $workDir -Recurse -Force } catch {}
|
||||
try { Remove-Item -Path $workDir -Recurse -Force } catch { Log "WARNING: could not delete temp directory ${workDir}: $_" }
|
||||
|
||||
if (Test-Path $workDir) {
|
||||
Log "WARNING: some items could not be deleted in $workDir"
|
||||
|
||||
Reference in New Issue
Block a user