After upgrading a solution with 25 projects from VS2012 Update 4 to VS2015 RTM (14.0.23107.0), I get the following error while building one of the projects:
(...) MSB4018: 'The "Link" task failed unexpectedly. (...) System.NullReferenceException: Object reference not set to an instance of an object.' (...)
Here the full output:
1>------ Build started: Project: Buttons, Configuration: Release Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: The "Link" task failed unexpectedly.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: at Microsoft.Build.CPPTasks.Link.ForcedRebuildRequired()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.ComputeOutOfDateSources()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.SkipTaskExecution()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: at Microsoft.Build.Utilities.ToolTask.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,5): error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.Execute()
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(643,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(643,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__1.MoveNext()
========== Build: 0 succeeded, 1 failed, 24 up-to-date, 0 skipped ==========
I've tried already several suggested solutions related to MSB4018 without any success. The error 'The "Link" task failed unexpectedly' wasn't even indexed by Google yet. I guess this issue is somehow related to the type of the project because it's the only project in the solution that's used as a resource DLL (i.e. with no entry point, etc.). The only changes that have been made to the project file by VS2015 are "ToolsVersion: 4.0 => 14.0" and "PlatformToolset: v110_xp => v140_xp".
Does anyone has a solution for this?
I've managed to fix this issue myself and would like to document the solution here for future reference.
The following error was caused by an empty XML element in the project file:
The empty element was accessed by the 'Link' task, which just failed:
Removing the respective element fixed the issue:
<Link><GenerateDebugInformation></GenerateDebugInformation></Link>
Hint: As it can be seen in other posts, many of the MSB4018 errors seem to be related to project files containing unexpected values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With