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:
- MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
The empty element was accessed by the ‘Link‘ task, which just failed:
- MSB4018: ‘The "Link" task failed unexpectedly.
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.