How to debug msbuild?
See original GitHub issueHey,
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
- new csproj with .NET Sdk
- 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:
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:
- Created 5 years ago
- Comments:8 (8 by maintainers)
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!
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.