Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions start-modules/10-Module.Logging.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ function Start-ToolkitLog {
#>
param([string]$ToolName)

# Clean up leftover transcripts
# Clean up leftover transcripts. Stop-Transcript throws when no transcript is
# active ("The host is not currently transcribing"), which is expected on a
# fresh run, so that benign case is silenced instead of surfaced as a warning.
try { Stop-Transcript -ErrorAction SilentlyContinue } catch {
Write-Warning "start-modules\10-Module.Logging.ps1, Start-ToolkitLog: $($_.Exception.Message)"
if ($_.Exception.Message -notmatch 'not currently transcribing') {
Write-Warning "start-modules\10-Module.Logging.ps1, Start-ToolkitLog: $($_.Exception.Message)"
}
}

$dateTime = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
Expand Down
17 changes: 12 additions & 5 deletions start-modules/90-Skeleton.Main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ function Invoke-WinToolkitSetup {

# Initialize Logging
Start-ToolkitLog "WinToolkitStarter"

# Localization must be resolved before any path that emits translated
# messages. In particular, Initialize-UpdateServicesState can trigger an
# early Windows Update service restore (when a previous run left a
# RestoreFailed state) and that restore prints translation keys such as
# uiText.resettingWindowsUpdateServices. Resolving first prevents
# "[MISSING TRANSLATION]" warnings during that startup recovery.
$null = Resolve-SourceTextLanguage -RequestedLanguage $Language

Initialize-UpdateServicesState

if ($PSVersionTable.PSVersion.Major -lt 7) {
Expand All @@ -39,10 +48,6 @@ function Invoke-WinToolkitSetup {
throw 'start-core.ps1 must be started by the elevated start.ps1 stub.'
}

# Localization is prepared here, after logging exists and after the
# elevation check, so the GitHub API is never queried twice per run.
$null = Resolve-SourceTextLanguage -RequestedLanguage $Language

Show-Header -Title $script:AppConfig.Header.Title -Version $script:AppConfig.Header.Version

foreach ($repair in @(
Expand Down Expand Up @@ -172,7 +177,9 @@ function Invoke-WinToolkitSetup {
finally {
Invoke-StartUpdateServices
try { Stop-Transcript -ErrorAction SilentlyContinue } catch {
Write-Warning "start-modules\90-Skeleton.Main.ps1, Invoke-WinToolkitSetup: $($_.Exception.Message)"
if ($_.Exception.Message -notmatch 'not currently transcribing') {
Write-Warning "start-modules\90-Skeleton.Main.ps1, Invoke-WinToolkitSetup: $($_.Exception.Message)"
}
}
$ErrorActionPreference = $previousErrorActionPreference
}
Expand Down