How to debug msbuild issues

To debug msbuild build failures, you can run following from VS command prompt to get more build log output

msbuild /v:diag <solutionname>

If you want to log messages for debug during build, you can use Message tasks. For example, use Message task inside a target

<Target Name="DisplayMessages">
  <Message Text="Project File Name = $(MSBuildProjectFile)" />
  <Message Text="Project Extension = $(MSBuildProjectExtension)" />
</Target>

If you are doing build in VS2010 IDE, you can follow these steps to turn on verbose building to help debug msbuild issues.

  1. Open Visual Studio and go into the Tools->Options menu
  2. Go to Projects and Solutions->Build and Run and set MSBuild project build output verbosity to Diagnostic.
  3. Rebuild your project and now the output will show you all the environment variables and parameters.

Comments

5 responses to “How to debug msbuild issues”

Leave a Reply