Skip to content

[Bug]: Insufficient permissions on %SystemRoot%\TEMP results in nonspecific XamlTaskFactory error #10759

Open

Description

Issue Description

If permissions on %SystemRoot%\Temp are revoked, invoking a custom Xaml task declared via UsingTask causes MSBuild to log a nonspecific error implicating the (perfectly valid) command invocation file/line location as its cause.

Steps to Reproduce

I'm locally seeing this using VS and CUDA. I think the important thing is having a project with a Build Customisation set to some external thing which declares custom tasks via UsingTask, and then actually using those tasks in the project. In this instance it's CudaCompile.

  • In VS: File -> New -> Project -> CUDA 12.3 Runtime (or set up your test project with build customisation and task invocation)
  • Build the example project. It works fine.
  • Open cmd.exe as administrator and run cacls C:\Windows\Temp /E /R everyone
  • Rebuild the project (or Clean then Build).
  • Note the error described above.
  • Run cacls C:\Windows\Temp /E /G everyone:F in the admin cmd.exe
  • Rebuild again. Now it works again.

Expected Behavior

If %SystemRoot%\TEMP doesn't have the requisite permissions, MSBuild should log an error saying so.

Actual Behavior

MSBuild logs an error implicating an innocent task invocation.

Analysis

Hi all, thought I'd report a bug I ran into which was tricky to solve. I have found a workaround, but I think the logging could have been much more helpful. I also hope that writing something here will help others who run into this in future.

As a bit of background, somehow the permissions on my C:\Windows\TEMP directory were revoked. Some cursory googling suggests this can happen in Windows updates. I think in my case it might have been in the process of installing VS 2022, but I'm not sure. This caused my project builds which include CUDA 12.3.targets to fail in a mysterious way:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 12.3.targets(799,9): error MSB3686: Unable to create Xaml task.  Compilation failed.   [C:\Users\esther.okeefe\source\re
pos\MSBuildBug\MSBuildBug\MSBuildBug.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 12.3.targets(799,9): error MSB3686: Source file 'C:\Windows\TEMP\k5qvwvgi.0.cs' could not be found [C:\Users\esther.okee
fe\source\repos\MSBuildBug\MSBuildBug\MSBuildBug.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 12.3.targets(799,9): error MSB3686:  [C:\Users\esther.okeefe\source\repos\MSBuildBug\MSBuildBug\MSBuildBug.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 12.3.targets(799,9): error MSB4175: The task factory "XamlTaskFactory" could not be loaded from the assembly "Microsoft.
Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Object reference not set to an instance of an object. [C:\Users\esther.okeefe\source\repos\MSBuildBug\MSBuildBug\MSBuildBug.vcxproj]

The file/line number given is a red herring, as the error has nothing to do with the particular file. Changing the permissions on the system temp folder is not something anyone would think to do manually, so if this issue ever crops up the user isn't going to have any idea what's going on.

In VS the error looks like this, which doesn't mention C:\Windows\TEMP and draws even more attention to the (actually perfectly innocent) file/line number:
image

Looking at the MSBuild code I saw that setting MSBUILDWRITEXAMLTASK=1 would take a different code path, and indeed doing so avoids the error because it doesn't access %SystemRoot%\Temp.

This led me to check the permissions on all my temp folders. Running cacls C:\Windows\Temp /E /G everyone:F from an administrator prompt resolved the issue, and running cacls C:\Windows\Temp /E /R everyone causes it to come back, whence the repro steps above.

Versions & Configurations

Microsoft (R) Build Engine version 16.10.2+857e5a733 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

16.10.2.30804

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

Metadata

Assignees

Labels

Good First IssueSelf-contained issues good for first-time contributors.Priority:3Work that is nice to havebughelp wantedIssues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim.needs-more-infoIssues that need more info to continue investigation.triaged

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions