Skip to content

Fix UTF-16 encoded log files in Windows CI test runs#15772

Merged
radical merged 3 commits intomainfrom
copilot/fix-logs-format-to-utf8
Apr 2, 2026
Merged

Fix UTF-16 encoded log files in Windows CI test runs#15772
radical merged 3 commits intomainfrom
copilot/fix-logs-format-to-utf8

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

Description

Log files produced during Windows CI runs were being saved in UTF-16 format, making them unreadable by default on Linux/macOS. Several independent encoding issues across the test infrastructure were contributing to this.

Root causes & fixes

  • eng/Xunit3/Microsoft.Testing.Platform.targetsWriteLinesToFile without Encoding="UTF-8" defaults to UTF-16 on older MSBuild versions (pre-17.3.4). Added explicit Encoding="UTF-8".

  • eng/SpecializedTestRunsheetBuilderBase.targets — Used cmd.exe echo ... > file to write the command header, which inherits the current console code page (non-UTF-8 by default on Windows). Replaced with WriteLinesToFile with Encoding="UTF-8", consistent with the pattern in Microsoft.Testing.Platform.targets.

  • eng/scripts/cli-starter-validation.ps1 — Used *> redirect and Set-Content without encoding, which defaults to UTF-16 in Windows PowerShell 5.1. Changed to *>&1 | Out-File -Encoding utf8 and -Encoding utf8 on all Set-Content calls.

  • tests/helix/send-to-helix-inner.proj — Added chcp 65001 as a Windows Helix pre-command to set the console code page to UTF-8 before any test execution.

  • .github/workflows/run-tests.yml — Added [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 in both Windows test steps before invoking the test runner.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI changed the title [WIP] Fix log files to be saved in UTF-8 format instead of UTF-16 Fix UTF-16 encoded log files in Windows CI test runs Apr 1, 2026
Copilot AI requested a review from karolz-ms April 1, 2026 22:49
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15772

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15772"

@karolz-ms karolz-ms marked this pull request as ready for review April 2, 2026 16:41
Copilot AI review requested due to automatic review settings April 2, 2026 16:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the test/CI infrastructure to ensure logs generated on Windows are written using UTF-8 (instead of UTF-16 or console-codepage-dependent encodings), improving cross-platform readability of collected artifacts.

Changes:

  • MSBuild: explicitly set Encoding="UTF-8" for WriteLinesToFile when writing command headers to test stdout logs.
  • MSBuild: replace cmd.exe echo > file header writing with WriteLinesToFile + UTF-8 encoding.
  • PowerShell & CI: ensure Windows workflow/script output files are written in UTF-8 and set Windows console/code page to UTF-8 for Helix/GitHub Actions runs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/helix/send-to-helix-inner.proj Adds a Windows Helix pre-command to switch console code page to UTF-8.
eng/Xunit3/Microsoft.Testing.Platform.targets Forces UTF-8 when writing the command-line header into captured stdout logs.
eng/SpecializedTestRunsheetBuilderBase.targets Replaces echo-based header writing with WriteLinesToFile using UTF-8.
eng/scripts/cli-starter-validation.ps1 Writes combined logs and stop logs explicitly as UTF-8 to avoid UTF-16 defaults.
.github/workflows/run-tests.yml Sets console output encoding to UTF-8 for Windows test steps.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@radical radical enabled auto-merge (squash) April 2, 2026 17:52
@radical radical merged commit 43c0500 into main Apr 2, 2026
521 of 524 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

🎬 CLI E2E Test Recordings — 55 recordings uploaded (commit 8b7b7a3)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23913983842

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some logs from Windows runs are saved in UTF-16 format

4 participants