-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Feature Request]: Make it easier for overriding ToolTask temp rsp location #9229
Comments
I guess this problem only occurs on Windows, as POSIX doesn't have separate ANSI and Unicode functions for opening files. On Windows though, the temp directory is per user. So MSBuild could be changed to omit the user name from the path entirely, when running on Windows. This wouldn't need any new environment variables. |
@KalleOlaviNiemitalo I like that. Took a look why the username was appended, it dosnt seem theres a clear reason: And before it was not, just dumping the file in the tmp location. |
…de, and Username containing Unicode chars. dotnet#9229
If there is some security objection to omitting the user name on Windows, then an alternative would be to use the SecurityIdentifier instead; it is as unique as the user name, and its ToString() contains ASCII characters only. That might require referencing additional libraries, though. |
The only reason I could see there being a security objection, would be if multiple users used the same tmp location. |
@Forgind Since you did the change, what do you think?
|
…de, and Username containing Unicode chars. dotnet#9229
I agree, I don't think this is necessary on Windows msbuild/src/Shared/TempFileUtilities.cs Line 39 in 60ae06f
Generally the user name is already in the Windows temp path, and if it isn't -- you're hopefully sending it some other secure place. Should that line be moved down in the non Windows path only? |
I think removing the UserName on Windows is probably ok. The reason I initially kept it for Windows even though it was unnecessary for the security change was so that if users are looking for their MSBuild-specific temp directory, we can give them clear guidance instead of having guidance that depends on your OS. I can ask someone internally what he thinks—I don't officially work on MSBuild anymore. |
Summary
A recent issue for us that we stumbled on was a Task, inheriting from ToolTask that didnt handle Unicode chars.
The User Name contained Unitycode chars, and ToolTask puts command line args into a temp response file
https://github.com/dotnet/msbuild/blob/main/src/Utilities/ToolTask.cs#L564C61-L564C61
The issue was reported to the owners of the Task, but trying to find a way to unblock is quite hard.
The rsp path are set as:
Path.Combine(Path.GetTempPath(), $"MSBuildTemp{Environment.UserName}");
GetTempPath
can be overriden by changing the TMP/TEMP User env vars.But
UserName
are no way to override AFAICT today.Background and Motivation
As a consumer of a NuGet package, containing Task with such a problem, I would like to be able to not be stuck with this issue again, without being able to fix it myself.
Proposed Feature
Possible solutions on the top of my head:
$"MSBuildTemp{Environment.UserName}")
Edit:
Alternative Designs
No response
The text was updated successfully, but these errors were encountered: