Commit 1d69366
authored
Add Helpers to aide Debugging MSBuild tasks (#20695)
One thing that is very useful is the ability to debug
your Tasks while they are being run on a build process.
This is possible thanks to the `MSBUILDDEBUGONSTART`
environment variable. When set to `2` this will force
MSBuild to wait for a debugger connection before
continuing. You will see the following prompt.
```dotnetcli
Waiting for debugger to attach (dotnet PID 13001). Press enter to continue...
```
You can then use VS or VSCode to attach to this process
and debug you tasks.
This commit adds code helper tasks.json and launch.json
entires to help make this debugging process a bit easier.
You can start your test app with the `dotnet-local`
script (so it uses your maui build)
```dotnetcli
MSBUILDDEBUGONSTART=2 ~/<some maui checkout>/dotnet-local.sh build -m:1
```
```dotnetcli
MSBUILDDEBUGONSTART=2 ~/<some maui checkout>/dotnet-local.sh build -m:1
```
```dotnetcli
set MSBUILDDEBUGONSTART=2
~/<some maui checkout>/dotnet-local.cmd build -m:1
```
---
Note: the `-m:1` is important as it restricts MSBuild to 1 node.
Once MSBuild starts it will print the following
```dotnetcli
Waiting for debugger to attach (dotnet PID xxxx). Press enter to continue...
```
You need to copy the PID value so we can use this in the IDE.
For Visual Studio you can use the `Attach to Process` menu option,
while you have the Microsoft.Maui.sln solution open.
For VSCode open the workspace then use the `Attach to Process`
Run and Debug option. You will be prompted for the PID
and it will then connect.
Once connected go back to your command prompt and
press ENTER so that the MSBuild process can continue.
You will be able to set breakpoints in Tasks (but not Targets)
and step through code from this point on.
If you want to test in-tree in VSCode the `Build Platform Sample`
command will ask you if you want to debug MSBuild tasks and
fill in the `MSBUILDDEBUGONSTART` for you. The PID text will
appear in the `Terminal` window in VSCode. You can then use
the `Attach to Process` Run and Debug option to attach to
the process.1 parent 0c02e4b commit 1d69366
3 files changed
Lines changed: 84 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
304 | 355 | | |
305 | 356 | | |
306 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
63 | 73 | | |
64 | 74 | | |
65 | 75 | | |
| |||
0 commit comments