The “CL” task failed unexpectedly in vs2017


I have met a problem as following when building a VC++ MFC project in visual stdio 2017. I reinstalled my vs 2017 but it still exists.It has nothing to do with my code and all projects running correctly before can't be built because of the same problem. The error specifies the code

<!-- Precompiled headers - need to build them first -->
<CL Condition="'%(ClCompile.PrecompiledHeader)' == 'Create' and '%
(ClCompile.ExcludedFromBuild)'!='true' and '%(ClCompile.CompilerIteration)' 
== ''"
in  D:\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets.

I tried to disable PrecompiledHeader but it doesn't work.

MSB4018   The “CL” task failed unexpectedly
System.TypeInitializationException: The type initializer for
“Microsoft.Build.Utilities.FileTracker”threw an exception。 --->
System.IO.FileNotFoundException: The system can not find the file
specified. (Exception from HRESULT:0x80070002)    in
errorCode, IntPtr errorInfo)    in
errorCode)    in
path)    in Microsoft.Build.Utilities.FileTracker..cctor()    --- End
of internal exception stack trace ---    in
sources)    in Microsoft.Build.CPPTasks.CL.ComputeOutOfDateSources()  
in Microsoft.Build.CPPTasks.TrackedVCToolTask.SkipTaskExecution()   
in Microsoft.Build.Utilities.ToolTask.Execute()    in
Microsoft.Build.CPPTasks.TrackedVCToolTask.Execute()    in
asked on Stack Overflow May 24, 2017 by aStupidCoder • edited May 24, 2017 by Ken White

1 Answer


Check the TEMP and TMP environment variables (both user and system) and set permissions to Full Control for both those folders.

You can refer to a similar issue here.

answered on Stack Overflow May 5, 2019 by Angad Singh

User contributions licensed under CC BY-SA 3.0