New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add /waitfordebugger
argument to MGCB.
#8227
Open
dellis1972
wants to merge
5
commits into
MonoGame:develop
Choose a base branch
from
dellis1972:attachdebugger
base: develop
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The call to `System.Diagnostics.Debugger.Launch` is not supported on Unix based platforms. This makes debugging `MGCB.exe` and Content Pipeline extensions difficult. So lets add a new argument which will make `MGCB.exe` wait for a debugger to attach. Also add a extra update to the `launch.json` to demonstrate how to attach the `dotnet` debugger to an existing process. This new system will also work on Windows. To use this in VSCode you can add the following to the `launch.json` ```json { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Attach to Process", "type": "coreclr", "request": "attach", "processId": "${input.processid}", } ], "inputs": [ { "id": "processid", "type": "promptString", "default": "0", "description": "Enter Process Id of process to attach to." } ] } ``` you can then add the following to your `csproj`. ``` <MonoGameMGCBAdditionalArguments>/waitfordebugger</MonoGameMGCBAdditionalArguments> ``` This will cause the `MGCB.exe` to print the ProcessId to the console during the build and wait for the debugger to attach. Once you have the ProcessId you can run the VSCode `Attach to Process` and enter the ProcessId when prompted. The debugger should then attach. If you want to prcess without attaching the debugger just hit any key in the console or terminal windows where `MGCB.exe` is running.
harry-cpp
reviewed
Apr 22, 2024
{ | ||
var currentProcess = Process.GetCurrentProcess(); | ||
Console.WriteLine($"Waiting for debugger to attach ({currentProcess.MainModule.FileName} PID {currentProcess.Id}). Press any key to continue without debugger."); | ||
while (!Debugger.IsAttached) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Braces should be be in new lines.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The call to
System.Diagnostics.Debugger.Launch
is not supported on Unix based platforms. This makesdebugging
MGCB.exe
and Content Pipeline extensions difficult.So lets add a new argument which will make
MGCB.exe
wait for a debugger to attach. Also add a extraupdate to the
launch.json
to demonstrate how toattach the
dotnet
debugger to an existing process.This new system will also work on Windows.
To use this in VSCode you can add the following to the
launch.json
you can then add the following to your
csproj
.This will cause the
MGCB.exe
to print the ProcessId to the console during the build and wait for the debugger to attach. Once you have the ProcessId you can run the VSCodeAttach to Process
and enter the ProcessId when prompted. The debugger should then attach.If you want to prcess without attaching the debugger just hit any key in the console or terminal windows where
MGCB.exe
is running.