question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to debug msbuild?

See original GitHub issue

Hey,

So I would like to investigate a problem related to slow RAR in msbuild and while I have been able to initially hack something to debug msbuild, that was very convoluted, copying files around from regular Sdk…etc.

So I would like to do this more cleanly and follow a more deterministic procedure to debug directly MsBuild project from MsBuild.sln solution (so it is issuing a dotnet msbuild.dll or msbuild.exe) for

  1. new csproj with .NET Sdk
  2. regular old csproj

Which repository should I build, variable that I should set…etc.? (Or I could avoid building by reusing maybe an installed dotnet folder?)

For new csproj

Let’s try just on the new csproj format for now, starting with a plain dotnet new --name Helloworld

Assuming that I built this repository, and I’m setting the MSBuildSDKsPath to point to the artifacts\Debug\bin\Sdks

I’m getting the following error:

image

Project "C:\Work\tmp\HelloWorld\Helloworld.csproj" on node 1 (default targets).
C:\Code\dotnet\sdk\artifacts\Debug\bin\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props(33,11): error MSB4226: The imported project
 "C:\Code\msbuild\artifacts\Debug\bin\MSBuild\net472\Current\Microsoft.Common.props" was not found. Also, tried to find
 "Current\Microsoft.Common.props" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)
\MSBuild" . These search paths are defined in "C:\Code\msbuild\artifacts\Debug\bin\MSBuild\net472\MSBuild.exe.Config".
Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search pat
hs. [C:\Work\tmp\HelloWorld\Helloworld.csproj]
Done Building Project "C:\Work\tmp\HelloWorld\Helloworld.csproj" (default targets) -- FAILED.

It is trying to resolve artifacts\Debug\bin\MSBuild\net472\Current\Microsoft.Common.props which is not in this folder. Not sure why it is trying Current by default, while the solution seems to build in this file in artifacts\Debug\bin\15.0\Microsoft.Common.props , so assume that the tooling version should be 15.0… but still, can I setup a MsBuild special variable path for pointing to this folder?

So likely after that, it will complain about missing NuGet resolver or similar. How do I pass them through?

cc: @davkean @nguerrera

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
xoofxcommented, Dec 5, 2018

Yes. There’s definitely room for improvement, but IIRC we ran into a lot of problems integrating the bootstrap process with the msbuild.exe project, because we produce NuGet packages from the project and must not pollute them with a bunch of extra files.

Ok, it seems to work and better than all the fragile hacks to setup the correct env variables I was previously using… I will try to workaround the iteration maybe by adding a temp task to copy of the relevant assemblies directly to the bootstrap folder. Thanks!

1reaction
rainersigwaldcommented, Dec 5, 2018

You’re trying to run a just-built MSBuild (in the MSBuild repo) from VS? That doesn’t work. You can build from the command line and run the bootstrapped MSBuild from artifacts\Debug\bootstrap\net472\MSBuild\Current\Bin\MSBuild.exe.

For ease of debugging, you can set MSBUILDDEBUGONSTART=1 (full framework) or =2 (.NET Core) to cause MSBuild to break on start. Be careful combining this with multiproc builds–every MSBuild node will break on start, which is often not what you want.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to debug MSBuild Customtask
This is what I do... In the Project Properties dialog on the Debug Tab Select "Start an External App" - put C:\WINDOWS\Microsoft.NET\Framework\ ...
Read more >
Debugging MSBuild | David's Blog
In my opinion, the best way to understand how to debug MSBuild is to actually dive into the logs and see if we...
Read more >
Debugging MSBuild script with Visual Studio
Scenario 1 – Command Line only ... You should now have these keys, assuming C: is your system drive. image. Run MSBuild /?...
Read more >
How to do a Debug, Release or both builds with MSBuild
Try it. > msbuild test. proj /t:showconfigurations Building project, Debug > msbuild test.
Read more >
Building-Testing-and-Debugging-on-Full-Framework ...
Running Unit Tests · Open the MSBuild solution file ( MSBuild.Dev.slnf ) in Visual Studio. · Open the Test menu -> Windows ->...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found