-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Issue Description
On Japanese Windows systems, running msbuild directly in the console displays output correctly.
However, when piping the output (e.g., msbuild | more), the result becomes garbled. It seems that MSBuild outputs UTF-8, but when the output is piped, the Windows console expects text in the active code page (usually CP932 / Shift-JIS), leading to misinterpretation of multibyte characters.
This causes serious usability issues in environments where UTF-8 output cannot be correctly handled by standard console tools, and switching to UTF-8 (chcp 65001) is not an option due to system policy or tool incompatibility.
Steps to Reproduce
- Open
Developer Command Prompt for VS 2022on a Japanese Windows machine (default code page: 932). - Run
msbuild→ Output is readable.
C:\Program Files\Microsoft Visual Studio\2022\Professional>msbuild
MSBuild のバージョン 17.14.8+a7a4d5af0 (.NET Framework)
MSBUILD : error MSB1003: プロジェクト ファイルまたはソリューション ファイルを指定してください。現在の作業ディレクトリはプロジェクト ファイルまたはソリューション ファイルを含んでいません。
- Run
msbuild | more→ Output is garbled (UTF-8 interpreted as Shift-JIS).
C:\Program Files\Microsoft Visual Studio\2022\Professional>msbuild | more
MSBuild 縺ョ繝舌・繧ク繝ァ繝ウ 17.14.8+a7a4d5af0 (.NET Framework)
MSBUILD : error MSB1003: 繝励Ο繧ク繧ァ繧ッ繝・繝輔ぃ繧、繝ォ縺セ縺溘・繧ス繝ェ繝・繝シ繧キ繝ァ繝ウ 繝輔ぃ繧、繝ォ繧呈欠螳壹@縺ヲ縺上□ 縺輔>縲ら樟蝨ィ縺ョ菴懈・ュ繝・ぅ繝ャ繧ッ繝医Μ縺ッ繝励Ο繧ク繧ァ繧ッ繝・繝輔ぃ繧、繝ォ縺セ縺溘・繧ス繝ェ繝・繝シ繧キ繝ァ繝ウ 繝輔ぃ繧、繝ォ繧貞性繧薙〒縺・∪縺帙s縲・
Expected Behavior
MSBuild should provide a way to emit text in the console's active code page when writing to a pipe or redirected output, or detect the output target and adjust accordingly.
- Redirecting output to a file (e.g.,
msbuild > log.txt) and then viewing it with encoding conversion does not solve the problem, as we require real-time output. - Using
chcp 65001is not feasible due to system policy and compatibility issues with other tools.
Actual Behavior
See "Steps to Reproduce"
Analysis
No response
Versions & Configurations
- MSBuild version: 17.14.8+a7a4d5af0 (.NET Framework)
- OS: Windows 10/11 Japanese edition
- Locale: Japanese
- Console code page: 932