The “CL” task failed unexpectedly in vs2017

1

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
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32
errorCode, IntPtr errorInfo)    in
Microsoft.Build.Shared.NativeMethodsShared.ThrowExceptionForErrorCode(Int32
errorCode)    in
Microsoft.Build.Shared.NativeMethodsShared.GetLongFilePath(String
path)    in Microsoft.Build.Utilities.FileTracker..cctor()    --- End
of internal exception stack trace ---    in
Microsoft.Build.Utilities.FileTracker.FormatRootingMarker(ITaskItem[]
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
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
in
Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
visual-studio-2017
asked on Stack Overflow May 24, 2017 by aStupidCoder • edited May 24, 2017 by Ken White

1 Answer

0

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