Jenkinsfile Msbuild: error MC1000

Hello all,

Currently, I have a Jenkins multibranch pipeline. It clones my git repo and builds the solution via a Jenkinsfile. The Jenkinsfile has 5 stages:

  1. checkout scm
  2. restore nugets (using nuget.exe)
  3. Build Debug config of solution using msbuild from command line --> bat “”${tool ‘VS2017’}"\MsBuild.exe %WORKSPACE%\mysolution.sln /p:Configuration=Debug /p:Platform=“x64"”
  4. Build Release config of solution using msbuild from command line
  5. Build Custom config of solution using msbuild from command line

Intermittently, the builds fail. The error I get:
(MarkupCompilePass1 target) ->
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(268,9): error MC1000: Unknown build error, ‘Object reference not set to an instance of an object.’

Not sure wy this happens. But as mentioned it only happens sometimes. Other times the build passes successfully. I have a feeling this has to do with an update as this never hapened before. Has anyone come across this?