Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On windows there can be problems with Tools that do not support Unicode #9232

Merged
merged 2 commits into from
Oct 5, 2023
Merged
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
9 changes: 8 additions & 1 deletion src/Shared/TempFileUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ internal static partial class FileUtilities
// Lower order bits correspond to the same for "group" or "other" users.
private const int userRWX = 0x100 | 0x80 | 0x40;
private static string tempFileDirectory = null;
private const string msbuildTempFolderPrefix = "MSBuildTemp";

internal static string TempFileDirectory
{
get
Expand All @@ -36,7 +38,12 @@ internal static void ClearTempFileDirectory()
// For all native calls, directly check their return values to prevent bad actors from getting in between checking if a directory exists and returning it.
private static string CreateFolderUnderTemp()
{
string basePath = Path.Combine(Path.GetTempPath(), $"MSBuildTemp{Environment.UserName}");
// On windows Username with Unicode chars can give issues, so we dont append username to the temp folder name.
string msbuildTempFolder = NativeMethodsShared.IsWindows ?
msbuildTempFolderPrefix :
msbuildTempFolderPrefix + Environment.UserName;

string basePath = Path.Combine(Path.GetTempPath(), msbuildTempFolder);

if (NativeMethodsShared.IsLinux && NativeMethodsShared.mkdir(basePath, userRWX) != 0)
{
Expand Down