-
Notifications
You must be signed in to change notification settings - Fork 153
/
launch.json
854 lines (854 loc) · 66.7 KB
/
launch.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
{
"configurations": [
//https://jasonwatmore.com/post/2021/06/24/vs-code-net-debug-a-net-web-app-in-visual-studio-code
//https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.youtube.com/watch?v=k0hpant9wXo
{
"name": "Launch: Catalogs Service",
"type": "coreclr",
"request": "launch",
//https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#launchsettingsjson-support
"launchSettingsProfile": "Catalogs.Api.Http",
"preLaunchTask": "build: catalogs",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set bin and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "bin/Debug/net7.0/FoodDelivery.Services.Catalogs.Api.dll",
"args": [],
// should be set expelcitly for root of our api project
"cwd": "${workspaceFolder}/src/Services/Catalogs/FoodDelivery.Services.Catalogs.Api",
"console": "externalTerminal",
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
}
},
//https://github.com/Trottero/dotnet-watch-attach
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-watch
{
"type": "dotnetwatchattach",
"request": "launch",
"name": "Watch: Catalogs Service",
"task": "watch: catalogs", // Label of watch task in tasks.json
// just the name of exe file not `full path` this exe name will use to attach to exe name process, and program should be `exe` file because processes to attach are `exe` when we use `attach` request type
// here we attach to existing running exe project, that already is run by watch command
"program": "FoodDelivery.Services.Catalogs.Api.exe"
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://github.com/microsoft/vscode-docker/issues/3597
//https://github.com/microsoft/vscode-docker/issues/3831
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
// here we use full build image for debugging but we change dcoker file `entrypoint` durring `docker run` for preventing launch app in docker container but with using new entrypoint our stage will run on app working directory and then in our launch.json we launch our app inner container with connecting to `catalogs-debug` container with `pipeTransport` and `vsdbg` (internaly use dcoker exec and run vsdb on container) and then with using coreclr type and prgram to run, it will run this program with `dotnet run` by coreclr and passed `args`
// for see data inner container `docker exec -it catalogs-debug bash`
{
"name": "Docker Launch: Catalogs Service",
"type": "coreclr",
"request": "launch",
"console": "externalTerminal",
"preLaunchTask": "docker-run-debug: catalogs",
"postDebugTask": "docker-remove-debug: catalogs",
// connecting debugger to docker container with using vsdbg inner container and ssh to our local source code
// it will run `exec -i <container name> /vsdbg/vsdbg ` inner container after that coreclr will launch our app with program attribute on container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"catalogs-debug"
],
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
//our container with base stage and without entrypoint is run on `app/` working directory
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set `bin` directory and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "/app/FoodDelivery.Services.Catalogs.Api.dll",
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/": "${workspaceRoot}"
},
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet#options-for-running-an-application
//https://github.com/microsoft/vscode-docker/issues/3597
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
"args": "--additionalProbingPath /root/nuget/packages --additionalProbingPath ~/.nuget/packages --additionalProbingPath /root/.nuget/fallbackpackages",
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
//because we use `base` image directly for running app, and we don't have any source code and nuggets and entrypoint (so our container not be launch) in base layer we should map source code and vsdbg as a volume or using in launch time in launch.json on base layer. In launch.json app will run with `pipeTransport` and type `coreclr` and after connecting to base layer container with running vsdb on the container and then coreclr will launch specified `program` with `dotnet run` on the container and pass `args` to `dotnet run` as launch program (nugget path, ... as --additionalProbingPath because our dll is in debug build and need to resolve all nugget dependecies that doesn't exist in this build).
//for see data inner container `docker exec -it catalogs-base bash`
{
"name": "Docker Launch Base: Catalogs Service",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "docker-run-base: catalogs",
"postDebugTask": "docker-remove-base: catalogs",
// connecting debugger to docker container with using vsdbg inner container and ssh to our local source code
// it will run `exec -i <container name> /vsdbg/vsdbg ` inner container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"catalogs-base"
],
"pipeCwd": "${workspaceFolder}",
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
//our container with base stage and without entrypoint is run on `app/` working directory
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set `bin` directory and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "bin/Debug/net7.0/FoodDelivery.Services.Catalogs.Api.dll",
//change working dicrectory inner container and inner /app working directory
"cwd": "src/Services/Catalogs/FoodDelivery.Services.Catalogs.Api",
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/app": "${workspaceRoot}"
},
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet#options-for-running-an-application
//https://github.com/microsoft/vscode-docker/issues/3597
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
"args": "--additionalProbingPath /root/nuget/packages --additionalProbingPath ~/.nuget/packages --additionalProbingPath /root/.nuget/fallbackpackages",
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
//for see data inner container `docker exec -it catalogs-dev`
{
"name": "Docker Attach: Catalogs Service",
"type": "coreclr",
// we will attach to a process from pop-up (here we should choose `FoodDelivery.Services.Catalogs`), inner `catalogs-dev` container when we connected through `pipeTransport` to the container
"request": "attach",
// connecting `vsdbg debugger` to `docker container` with using vsdbg inner container and ssh to our `local source code`
// `pipeTransport` will run `exec -i <container name> /vsdbg/vsdbg ` inner container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"catalogs-dev"
],
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/": "${workspaceRoot}"
},
},
//https://jasonwatmore.com/post/2021/06/24/vs-code-net-debug-a-net-web-app-in-visual-studio-code
//https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.youtube.com/watch?v=k0hpant9wXo
{
"name": "Launch: Customers Service",
"type": "coreclr",
"request": "launch",
//https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#launchsettingsjson-support
"launchSettingsProfile": "Customers.Api.Http",
"preLaunchTask": "build: customers",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set bin and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "bin/Debug/net7.0/FoodDelivery.Services.Customers.Api.dll",
"args": [],
// should be set expelcitly for root of our api project
"cwd": "${workspaceFolder}/src/Services/Customers/FoodDelivery.Services.Customers.Api",
"console": "externalTerminal",
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
}
},
//https://github.com/Trottero/dotnet-watch-attach
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-watch
{
"type": "dotnetwatchattach",
"request": "launch",
"name": "Watch: Customers Service",
"task": "watch: customers", // Label of watch task in tasks.json
// just the name of exe file not `full path`, this exe name will use to attach to exe name process, and program should be `exe` file because processes to attach are `exe` when we use `attach` request type through popup
// here we attach to existing running exe project, that already is run by watch command
"program": "FoodDelivery.Services.Customers.Api.exe"
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://github.com/microsoft/vscode-docker/issues/3597
//https://github.com/microsoft/vscode-docker/issues/3831
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
// here we use full build image for debugging but we change dcoker file `entrypoint` durring `docker run` for preventing launch app in docker container but with using new entrypoint our stage will run on app working directory and then in our launch.json we launch our app inner container with connecting to `customers-debug` container with `pipeTransport` and `vsdbg` (internaly use dcoker exec and run vsdb on container) and then with using coreclr type and prgram to run, it will run this program with `dotnet run` by coreclr and passed `args`
// for see data inner container `docker exec -it customers-debug bash`
{
"name": "Docker Launch: Customers Service",
"type": "coreclr",
"request": "launch",
"console": "externalTerminal",
"preLaunchTask": "docker-run-debug: customers",
"postDebugTask": "docker-remove-debug: customers",
// connecting debugger to docker container with using vsdbg inner container and ssh to our local source code
// it will run `exec -i <container name> /vsdbg/vsdbg ` inner container after that coreclr will launch our app with program attribute on container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"customers-debug"
],
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
//our container with base stage and without entrypoint is run on `app/` working directory
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set `bin` directory and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "/app/FoodDelivery.Services.Customers.Api.dll",
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/": "${workspaceRoot}"
},
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet#options-for-running-an-application
//https://github.com/microsoft/vscode-docker/issues/3597
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
"args": "--additionalProbingPath /root/nuget/packages --additionalProbingPath ~/.nuget/packages --additionalProbingPath /root/.nuget/fallbackpackages",
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
//because we use `base` image directly for running app, and we don't have any source code and nuggets and entrypoint (so our container not be launch) in base layer we should map source code and vsdbg as a volume or using in launch time in launch.json on base layer. In launch.json app will run with `pipeTransport` and type `coreclr` and after connecting to base layer container with running vsdb on the container and then coreclr will launch specified `program` with `dotnet run` on the container and pass `args` to `dotnet run` as launch program (nugget path, ... as --additionalProbingPath because our dll is in debug build and need to resolve all nugget dependecies that doesn't exist in this build).
//for see data inner container `docker exec -it customers-base bash`
{
"name": "Docker Launch Base: Customers Service",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "docker-run-base: customers",
"postDebugTask": "docker-remove-base: customers",
// connecting debugger to docker container with using vsdbg inner container and ssh to our local source code
// it will run `exec -i <container name> /vsdbg/vsdbg ` inner container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"customers-base"
],
"pipeCwd": "${workspaceFolder}",
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
//our container with base stage and without entrypoint is run on `app/` working directory
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set `bin` directory and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "bin/Debug/net7.0/FoodDelivery.Services.Customers.Api.dll",
//change working dicrectory inner container and inner /app working directory
"cwd": "src/Services/Customers/FoodDelivery.Services.Customers.Api",
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/app": "${workspaceRoot}"
},
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet#options-for-running-an-application
//https://github.com/microsoft/vscode-docker/issues/3597
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
"args": "--additionalProbingPath /root/nuget/packages --additionalProbingPath ~/.nuget/packages --additionalProbingPath /root/.nuget/fallbackpackages",
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
//for see data inner container `docker exec -it customers-dev`
{
"name": "Docker Attach: Customers Service",
"type": "coreclr",
// we will attach to a process from pop-up (here we should choose `FoodDelivery.Services.Customers`), inner `customers-dev` container when we connected through `pipeTransport` to the container
"request": "attach",
// connecting `vsdbg debugger` to `docker container` with using vsdbg inner container and ssh to our `local source code`
// `pipeTransport` will run `exec -i <container name> /vsdbg/vsdbg ` inner container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"customers-dev"
],
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/": "${workspaceRoot}"
},
},
//https://jasonwatmore.com/post/2021/06/24/vs-code-net-debug-a-net-web-app-in-visual-studio-code
//https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.youtube.com/watch?v=k0hpant9wXo
{
"name": "Launch: Identity Service",
"type": "coreclr",
"request": "launch",
//https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#launchsettingsjson-support
"launchSettingsProfile": "Identity.Api.Http",
"preLaunchTask": "build: identity",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set bin and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "bin/Debug/net7.0/FoodDelivery.Services.Identity.Api.dll",
"args": [],
// should be set expelcitly for root of our api project
"cwd": "${workspaceFolder}/src/Services/Identity/FoodDelivery.Services.Identity.Api",
"console": "externalTerminal",
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
}
},
//https://github.com/Trottero/dotnet-watch-attach
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-watch
{
"type": "dotnetwatchattach",
"request": "launch",
"name": "Watch: Identity Service",
"task": "watch: identity", // Label of watch task in tasks.json
// just the name of exe file not `full path`, this exe name will use to attach to exe name process, and program should be `exe` file because processes to attach are `exe` when we use `attach` request type through popup
// here we attach to existing running exe project, that already is run by watch command
"program": "FoodDelivery.Services.Identity.Api.exe"
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://github.com/microsoft/vscode-docker/issues/3597
//https://github.com/microsoft/vscode-docker/issues/3831
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
// here we use full build image for debugging but we change dcoker file `entrypoint` durring `docker run` for preventing launch app in docker container but with using new entrypoint our stage will run on app working directory and then in our launch.json we launch our app inner container with connecting to `identity-debug` container with `pipeTransport` and `vsdbg` (internaly use dcoker exec and run vsdb on container) and then with using coreclr type and prgram to run, it will run this program with `dotnet run` by coreclr and passed `args`
// for see data inner container `docker exec -it identity-debug bash`
{
"name": "Docker Launch: Identity Service",
"type": "coreclr",
"request": "launch",
"console": "externalTerminal",
"preLaunchTask": "docker-run-debug: identity",
"postDebugTask": "docker-remove-debug: identity",
// connecting debugger to docker container with using vsdbg inner container and ssh to our local source code
// it will run `exec -i <container name> /vsdbg/vsdbg ` inner container after that coreclr will launch our app with program attribute on container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"identity-debug"
],
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
//our container with base stage and without entrypoint is run on `app/` working directory
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set `bin` directory and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "/app/FoodDelivery.Services.Identity.Api.dll",
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/": "${workspaceRoot}"
},
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet#options-for-running-an-application
//https://github.com/microsoft/vscode-docker/issues/3597
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
"args": "--additionalProbingPath /root/nuget/packages --additionalProbingPath ~/.nuget/packages --additionalProbingPath /root/.nuget/fallbackpackages",
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
//because we use `base` image directly for running app, and we don't have any source code and nuggets and entrypoint (so our container not be launch) in base layer we should map source code and vsdbg as a volume or using in launch time in launch.json on base layer. In launch.json app will run with `pipeTransport` and type `coreclr` and after connecting to base layer container with running vsdb on the container and then coreclr will launch specified `program` with `dotnet run` on the container and pass `args` to `dotnet run` as launch program (nugget path, ... as --additionalProbingPath because our dll is in debug build and need to resolve all nugget dependecies that doesn't exist in this build).
//for see data inner container `docker exec -it identity-base bash`
{
"name": "Docker Launch Base: Identity Service",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "docker-run-base: identity",
"postDebugTask": "docker-remove-base: identity",
// connecting debugger to docker container with using vsdbg inner container and ssh to our local source code
// it will run `exec -i <container name> /vsdbg/vsdbg ` inner container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"identity-base"
],
"pipeCwd": "${workspaceFolder}",
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
//our container with base stage and without entrypoint is run on `app/` working directory
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set `bin` directory and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "bin/Debug/net7.0/FoodDelivery.Services.Identity.Api.dll",
//change working dicrectory inner container and inner /app working directory
"cwd": "src/Services/Identity/FoodDelivery.Services.Identity.Api",
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/app": "${workspaceRoot}"
},
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet#options-for-running-an-application
//https://github.com/microsoft/vscode-docker/issues/3597
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
"args": "--additionalProbingPath /root/nuget/packages --additionalProbingPath ~/.nuget/packages --additionalProbingPath /root/.nuget/fallbackpackages",
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
//for see data inner container `docker exec -it identity-dev`
{
"name": "Docker Attach: Identity Service",
"type": "coreclr",
// we will attach to a process from pop-up (here we should choose `FoodDelivery.Services.Identity`), inner `identity-dev` container when we connected through `pipeTransport` to the container
"request": "attach",
// connecting `vsdbg debugger` to `docker container` with using vsdbg inner container and ssh to our `local source code`
// `pipeTransport` will run `exec -i <container name> /vsdbg/vsdbg ` inner container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"identity-dev"
],
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/": "${workspaceRoot}"
},
},
//https://jasonwatmore.com/post/2021/06/24/vs-code-net-debug-a-net-web-app-in-visual-studio-code
//https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.youtube.com/watch?v=k0hpant9wXo
{
"name": "Launch: Gateway Service",
"type": "coreclr",
"request": "launch",
//https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#launchsettingsjson-support
"launchSettingsProfile": "ApiGateway.Http",
"preLaunchTask": "build: gateway",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set bin and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "bin/Debug/net7.0/FoodDelivery.ApiGateway.dll",
"args": [],
// should be set expelcitly for root of our api project
"cwd": "${workspaceFolder}/src/ApiGateway/FoodDelivery.ApiGateway",
"console": "externalTerminal",
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
}
},
//https://github.com/Trottero/dotnet-watch-attach
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-watch
{
"type": "dotnetwatchattach",
"request": "launch",
"name": "Watch: Gateway Service",
"task": "watch: gateway", // Label of watch task in tasks.json
// just the name of exe file not `full path`, this exe name will use to attach to exe name process, and program should be `exe` file because processes to attach are `exe` when we use `attach` request type through popup
// here we attach to existing running exe project, that already is run by watch command
"program": "FoodDelivery.ApiGateway.exe"
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://github.com/microsoft/vscode-docker/issues/3597
//https://github.com/microsoft/vscode-docker/issues/3831
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
// here we use full build image for debugging but we change dcoker file `entrypoint` durring `docker run` for preventing launch app in docker container but with using new entrypoint our stage will run on app working directory and then in our launch.json we launch our app inner container with connecting to `gateway-debug` container with `pipeTransport` and `vsdbg` (internaly use dcoker exec and run vsdb on container) and then with using coreclr type and prgram to run, it will run this program with `dotnet run` by coreclr and passed `args`
// for see data inner container `docker exec -it gateway-debug bash`
{
"name": "Docker Launch: Gateway Service",
"type": "coreclr",
"request": "launch",
"console": "externalTerminal",
"preLaunchTask": "docker-run-debug: gateway",
"postDebugTask": "docker-remove-debug: gateway",
// connecting debugger to docker container with using vsdbg inner container and ssh to our local source code
// it will run `exec -i <container name> /vsdbg/vsdbg ` inner container after that coreclr will launch our app with program attribute on container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"gateway-debug"
],
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
//our container with base stage and without entrypoint is run on `app/` working directory
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set `bin` directory and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "/app/FoodDelivery.ApiGateway.dll",
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/": "${workspaceRoot}"
},
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet#options-for-running-an-application
//https://github.com/microsoft/vscode-docker/issues/3597
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
"args": "--additionalProbingPath /root/nuget/packages --additionalProbingPath ~/.nuget/packages --additionalProbingPath /root/.nuget/fallbackpackages",
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
//because we use `base` image directly for running app, and we don't have any source code and nuggets and entrypoint (so our container not be launch) in base layer we should map source code and vsdbg as a volume or using in launch time in launch.json on base layer. In launch.json app will run with `pipeTransport` and type `coreclr` and after connecting to base layer container with running vsdb on the container and then coreclr will launch specified `program` with `dotnet run` on the container and pass `args` to `dotnet run` as launch program (nugget path, ... as --additionalProbingPath because our dll is in debug build and need to resolve all nugget dependecies that doesn't exist in this build).
//for see data inner container `docker exec -it gateway-base bash`
{
"name": "Docker Launch Base: Gateway Service",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "docker-run-base: gateway",
"postDebugTask": "docker-remove-base: gateway",
// connecting debugger to docker container with using vsdbg inner container and ssh to our local source code
// it will run `exec -i <container name> /vsdbg/vsdbg ` inner container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"gateway-base"
],
"pipeCwd": "${workspaceFolder}",
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
//our container with base stage and without entrypoint is run on `app/` working directory
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set `bin` directory and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "bin/Debug/net7.0/FoodDelivery.ApiGateway.dll",
//change working dicrectory inner container and inner /app working directory
"cwd": "src/ApiGateway/FoodDelivery.ApiGateway",
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/app": "${workspaceRoot}"
},
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet#options-for-running-an-application
//https://github.com/microsoft/vscode-docker/issues/3597
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
"args": "--additionalProbingPath /root/nuget/packages --additionalProbingPath ~/.nuget/packages --additionalProbingPath /root/.nuget/fallbackpackages",
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
//for see data inner container `docker exec -it gateway-dev`
{
"name": "Docker Attach: Gateway Service",
"type": "coreclr",
// we will attach to a process from pop-up (here we should choose `FoodDelivery.ApiGateway.exe`), inner `gateway-dev` container when we connected through `pipeTransport` to the container
"request": "attach",
// connecting `vsdbg debugger` to `docker container` with using vsdbg inner container and ssh to our `local source code`
// `pipeTransport` will run `exec -i <container name> /vsdbg/vsdbg ` inner container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"gateway-dev"
],
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/": "${workspaceRoot}"
},
},
//https://jasonwatmore.com/post/2021/06/24/vs-code-net-debug-a-net-web-app-in-visual-studio-code
//https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.youtube.com/watch?v=k0hpant9wXo
{
"name": "Launch: Orders Service",
"type": "coreclr",
"request": "launch",
//https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#launchsettingsjson-support
"launchSettingsProfile": "Orders.Api.Http",
"preLaunchTask": "build: orders",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set bin and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "bin/Debug/net7.0/FoodDelivery.Services.Orders.Api.dll",
"args": [],
// should be set expelcitly for root of our api project
"cwd": "${workspaceFolder}/src/Services/Orders/FoodDelivery.Services.Orders.Api",
"console": "externalTerminal",
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
}
},
//https://github.com/Trottero/dotnet-watch-attach
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-watch
{
"type": "dotnetwatchattach",
"request": "launch",
"name": "Watch: Orders Service",
"task": "watch: orders", // Label of watch task in tasks.json
// just the name of exe file not `full path`, this exe name will use to attach to exe name process, and program should be `exe` file because processes to attach are `exe` when we use `attach` request type through popup
// here we attach to existing running exe project, that already is run by watch command
"program": "FoodDelivery.Services.Orders.Api.exe"
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://github.com/microsoft/vscode-docker/issues/3597
//https://github.com/microsoft/vscode-docker/issues/3831
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
// here we use full build image for debugging but we change dcoker file `entrypoint` durring `docker run` for preventing launch app in docker container but with using new entrypoint our stage will run on app working directory and then in our launch.json we launch our app inner container with connecting to `orders-debug` container with `pipeTransport` and `vsdbg` (internaly use dcoker exec and run vsdb on container) and then with using coreclr type and prgram to run, it will run this program with `dotnet run` by coreclr and passed `args`
// for see data inner container `docker exec -it orders-debug bash`
{
"name": "Docker Launch: Orders Service",
"type": "coreclr",
"request": "launch",
"console": "externalTerminal",
"preLaunchTask": "docker-run-debug: orders",
"postDebugTask": "docker-remove-debug: orders",
// connecting debugger to docker container with using vsdbg inner container and ssh to our local source code
// it will run `exec -i <container name> /vsdbg/vsdbg ` inner container after that coreclr will launch our app with program attribute on container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"orders-debug"
],
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
//our container with base stage and without entrypoint is run on `app/` working directory
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set `bin` directory and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "/app/FoodDelivery.Services.Orders.Api.dll",
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/": "${workspaceRoot}"
},
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet#options-for-running-an-application
//https://github.com/microsoft/vscode-docker/issues/3597
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
"args": "--additionalProbingPath /root/nuget/packages --additionalProbingPath ~/.nuget/packages --additionalProbingPath /root/.nuget/fallbackpackages",
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
//because we use `base` image directly for running app, and we don't have any source code and nuggets and entrypoint (so our container not be launch) in base layer we should map source code and vsdbg as a volume or using in launch time in launch.json on base layer. In launch.json app will run with `pipeTransport` and type `coreclr` and after connecting to base layer container with running vsdb on the container and then coreclr will launch specified `program` with `dotnet run` on the container and pass `args` to `dotnet run` as launch program (nugget path, ... as --additionalProbingPath because our dll is in debug build and need to resolve all nugget dependecies that doesn't exist in this build).
//for see data inner container `docker exec -it orders-base bash`
{
"name": "Docker Launch Base: Orders Service",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "docker-run-base: orders",
"postDebugTask": "docker-remove-base: orders",
// connecting debugger to docker container with using vsdbg inner container and ssh to our local source code
// it will run `exec -i <container name> /vsdbg/vsdbg ` inner container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"orders-base"
],
"pipeCwd": "${workspaceFolder}",
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
//our container with base stage and without entrypoint is run on `app/` working directory
//when we `run` app `dll`, inner `api project` working directory (will resolve to current working directory for app) that contains appsetings.json files or inner `bin directory` because when run app dll in this directory `app working directory` and `current working directory` will be set `bin` directory and because appsettings.json are there, so app can find this `appsettings.json` files in current working directory but if we run app dll outside this directories app current working directory will be changed, and it can't find `appsettings.json` files in current working directory, so we should explicitly specify working dir in `cwd`, this problem doesn't exist for `.csproj files` and their working dir always resolve `correctly` based on `api project`
"program": "bin/Debug/net7.0/FoodDelivery.Services.Orders.Api.dll",
//change working dicrectory inner container and inner /app working directory
"cwd": "src/Services/Orders/FoodDelivery.Services.Orders.Api",
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/app": "${workspaceRoot}"
},
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet#options-for-running-an-application
//https://github.com/microsoft/vscode-docker/issues/3597
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
"args": "--additionalProbingPath /root/nuget/packages --additionalProbingPath ~/.nuget/packages --additionalProbingPath /root/.nuget/fallbackpackages",
},
//https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes
//https://www.richard-banks.org/2018/07/debugging-core-in-docker.html
//https://www.aaron-powell.com/posts/2019-04-04-debugging-dotnet-in-docker-with-vscode/
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes
//for see data inner container `docker exec -it orders-dev`
{
"name": "Docker Attach: Orders Service",
"type": "coreclr",
// we will attach to a process from pop-up (here we should choose `FoodDelivery.Services.Orders`), inner `orders-dev` container when we connected through `pipeTransport` to the container
"request": "attach",
// connecting `vsdbg debugger` to `docker container` with using vsdbg inner container and ssh to our `local source code`
// `pipeTransport` will run `exec -i <container name> /vsdbg/vsdbg ` inner container
"pipeTransport": {
"pipeArgs": [
"exec",
"-i",
"orders-dev"
],
"pipeProgram": "docker",
"quoteArgs": false,
"debuggerPath": "/vsdbg/vsdbg"
},
"justMyCode": false,
//To debug programs built on computers other than the Visual Studio Code computer (the dll and its pdbs are on the container), Visual Studio Code needs to be hold how to map file paths (SourceMap attribute), actually it maps path inner container pdbs to local path. This rule tells the debugger to change any `file paths` in `container pdbs` from `source` in SourceMap (`container pdb path`) to `target` in SourceMap (our `local code`) and replace it with the `local code` path. paths in the containers pdbs built and get from path during `dotnet build` in dockerfile.
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
//https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#building-and-deploying-the-application-and-pdbs
"sourceFileMap": {
"/": "${workspaceRoot}"
},
},
{
"name": "Attach: .Net Core",
"type": "coreclr",
"request": "attach"
}
]
}