MSB4018 The "CL" task failed unexpectedly in VS2015 Enterprise

0

I am using Visual Studio 2015 Enterprise and am unable to compile VC++ projects.

If I create a new Visual C++ Win32 Console Application with default settings and make no changes at all, building the project results in this error 13 times:

MSB4018: The "CL" task failed unexpectedly.

Does anyone know what can cause this error?

Full Error text:

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018: The "CL" task failed unexpectedly.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018: System.TypeInitializationException: The type initializer for 'Microsoft.Build.Utilities.FileTracker' threw an exception. ---> System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.Shared.NativeMethodsShared.ThrowExceptionForErrorCode(Int32 errorCode)
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.Shared.NativeMethodsShared.GetLongFilePath(String path)
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.Utilities.FileTracker..cctor()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    --- End of inner exception stack trace ---
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.CPPTasks.CL.ComputeOutOfDateSources()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.CPPTasks.TrackedVCToolTask.SkipTaskExecution()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.Utilities.ToolTask.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.CPPTasks.TrackedVCToolTask.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(253,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

I get the same errors on any VC++ project I try to compile from VS. (compiling from the command line seems to work)

This question about VS 2017 seems similar, but it doesn't look like it was ever answered.

I have tried uninstalling and re-installing Visual C++ (Image of Visual Studio 2015 Features List).

enter image description here

Image of Project Creation

enter image description here

Any help would be greatly appreciated, I am quite lost on this one.

c++
visual-c++
visual-studio-2015
msbuild
asked on Stack Overflow Jun 30, 2017 by Eric S. • edited Jul 1, 2017 by Nemus

1 Answer

0

MSB4018 The “CL” task failed unexpectedly in VS2015 Enterprise

According to the error log "MSB4018: The "CL" task failed unexpectedly.", it looks like something fundamental is wrong, we could try to uninstall and reinstall the Visual Studio to resolve this. If this issue still persist, please try to modify the TEMP and TMP environment variables (both user and system) and re-pointed the temp directories to other locations and set permissions to Full Control for both those folders.

You can refer to the similar issue here.

answered on Stack Overflow Jul 6, 2017 by Leo Liu-MSFT

User contributions licensed under CC BY-SA 3.0