MSBuild is open-source, which means you should be able to step through the execution of a build by following these steps.
- Developer Command Prompt:
msbuild --version
You should see something likeMSBuild version 17.3.1+362d18ee6 for .NET Framework
- Everything after the + is the hash. Copy that
git clone https://github.com/dotnet/msbuild
git checkout 362d18ee6
- VS -> MSBuild.Dev.slnf
- VS -> Tools -> Options -> Disable
Just My Code
- In a dev cmd prompt, navigate to your repro project
- Before you build it, type
set MSBUILDDEBUGONSTART=1
- 2 is an option that shows you the process ID to attach to
- Now reproduce your build failure
- When MSBuild launches you should see a prompt asking a debugger to attach
- If debugonstart is 1, you will see a prompt that shows a list of available debuggers.
- If debugonstart is 2, you will need to manually attach a debugger. In VS, it's Debug->Attach to proces.
- If neither works, try relaunching VS and make sure nothing is running as admin.
- Before continuing the run, add a breakpoint at the function that you want to breakpoint into.
- In VS you can go to the breakpoints window and add a new breakpoint.
- To be safe, the format should be
Namespace.Class.FunctionName
, butFunctionName
orClass.FunctionName
also work.
- To be safe, the format should be
- You can also manually find the file and place a breakpoint.
- In VS you can go to the breakpoints window and add a new breakpoint.
If the breakpoint always fails to bind:
- From an admin powershell, run
Deploy-MSBuild.ps1
supplying `-Destination:"Path/To/VS Install/MSBuild/Current/Bin"- The script will make a
Backup_...
file in the directory. - This should make absolutely certain that the source code you're looking at for MSBuild matches the source code VS will be using
- The script will make a
If it fails even after that... ¯_(ツ)_/¯