MSBuild Error MSB4018 in VS2015: Link task unexpectedly completed

After updating the solution with 25 projects from VS2012 Update 4 to VS2015 RTM (14.0.23107.0), I get the following error when building one of the projects:

(...) MSB4018: The Link task completed unexpectedly. (...) System.NullReferenceException: The reference to the object is not installed in the object instance. '(...)

Here's the full conclusion:

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 have already tried several proposed solutions related to MSB4018, without any success. Error "Task" The link "unexpectedly ended" has not yet been indexed by Google. I assume that this problem is somehow related to the type of project, because this is the only project in the solution that is used as a resource DLL (i.e., without an entry point, etc.). The only changes made to the VS2015 project file are "ToolsVersion: 4.0 => 14.0" and "PlatformToolset: v110_xp => v140_xp".

Does anyone have a solution for this?

+7
visual-studio-2015 visual-studio-2012 msbuild
source share
3 answers

I managed to solve this problem 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:

  • MSB4018: System.NullReferenceException: An object reference is not set to an object instance.

An empty element was called by the Link task, which simply failed:

  • MSB4018: The Link task completed unexpectedly.

Removing the corresponding item fixes the problem:

 <Link><GenerateDebugInformation></GenerateDebugInformation></Link> 

Hint. As you can see from other posts, many of the MSB4018 errors appear to be related to project files that contain unexpected values.

+10
source share

VS 2015: The solution to the problem is this: Goto:

Project Properties-> Connector-> Debugging-> Generating Debugging Information,

Set this property as Optimize for Debugging (/ DEBUG) or Not

Note. I observed a similar problem when it was empty (not installed).

It worked for me.

We hope you find this information helpful.

Good luck :).

+5
source share

Another solution is to remove all generated files from the latest build through the explorer window.

Delete all files in:

. \ Project \ Bin

. \ Project \ OBJ

As long as you can β€œClear” or β€œRebuild” directly through Visual Studio, this only fixes some of the files. Forcing all files to be recompiled, all memory cells will now be properly aligned, and the problem should be resolved.

+3
source share

All Articles