Skip to content

[Broken Build]: Build error with special characters in username on Windows #9528

@Danaozhong

Description

@Danaozhong

Issue Description

I am facing an build error after updating Visual Studio 2022 and installing the latest .NET framework. Every CMake build project fails with an error message from MSBuild. The issue seems to be related to the way MSBuild uses temporary paths.
I am using CMake, and was able to reproduce the issue with any CMake project I try to build. Before updating MSVC, these projects could be built without issues.

See the following build output:

PS C:\Work\CPP\cpp-cmake-bare\bin> cmake --build .
MSBuild version 17.8.3+195e7f5a3 for .NET Framework

  'C:\Users\123\AppData\Local\Temp\MSBuildTempFirstNameLastName' is not recognized as an internal or external command,
  operable program or batch file.
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(237,5): e
rror MSB8066: Custom build for 'C:\Work\CPP\cpp-cmake-bare\bin\CMakeFiles\d0c3deefe69ea22f50ff94701eaf2da5\gene
rate.stamp.rule' exited with code 1. [C:\Work\CPP\cpp-cmake-bare\bin\ZERO_CHECK.vcxproj]

Looking at my temporary folder, I can see that the folder C:\Users\123\AppData\Local\Temp\MSBuildTempFirstNameLastName indeed does not exist, but the folder C:\Users\123\AppData\Local\Temp\MSBuildTempFirstNameLastName(CompanyName does exist. Could it be that there is an issue with the way MSBuild picks a temp directory?

My MSBuild version is as follows:

PS C:\Users\123\source\repos> msbuild --version
MSBuild version 17.8.3+195e7f5a3 for .NET Framework
17.8.3.51904

I am using Windows 10 OS build 19044.3693.

I am not 100% if this is a CMake or MSBuild issue, but because the temporary path name starts with MSBuildTemp, and there was a recent PR modifying the MSBuild temporary path directory, I suspect it may be related to the way MSBuild handles the temporary directories on Windows.

Many thanks in advance, and sorry if I missed providing required information. Please let me know if there is something missing.

Steps to Reproduce

The issue seems to happen with any CMake project. I picked a random super-simple CMake project.

After cloning, run in a powershell:

mkdir bin
cd bin
cmake ..
cmake --build .

Expected Behavior

The cmake --build . should run successfully, and build the project.

Actual Behavior

crash during building:

PS C:\Work\CPP\Lightweight-C-ASCII-Table\bin> cmake --build .
MSBuild version 17.8.3+195e7f5a3 for .NET Framework

  'C:\Users\123\AppData\Local\Temp\MSBuildTempFirstNameLastName' is not recognized as an internal or external command,
  operable program or batch file.
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(237,5): error MSB8066: Custom build for 'C:\Wo
rk\CPP\Lightweight-C-ASCII-Table\bin\CMakeFiles\5d52f6b646fe4691cf3bf389522d7dd3\generate.stamp.rule' exited with code 1. [C:\Work\CPP\Lightweight-C-ASCII-T
able\bin\ZERO_CHECK.vcxproj]

Ask us questions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageHave yet to determine what bucket this goes in.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions