Skip to content
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

Unable to debug a .net core web workspace #1474

Closed
ravipal opened this issue Dec 9, 2019 · 5 comments · Fixed by #1639
Closed

Unable to debug a .net core web workspace #1474

ravipal opened this issue Dec 9, 2019 · 5 comments · Fixed by #1639
Labels
Milestone

Comments

@ravipal
Copy link
Contributor

ravipal commented Dec 9, 2019

Repro steps:

  1. Open an empty folder and launch terminal
  2. Create a mvc app ('dotnet new mvc')
  3. Save it as a workspace.
  4. 'Docker: Add docker files to workspace'. Docker debugging related tasks are added to workspace file.
  5. F5 show error
    Attaching the repro folder
    WebApp4.zip

Action: docker-launch
Error type: Error
Error Message: To debug with Docker you must first open a folder or workspace in VS Code.

Version: 0.9.0
OS: win32
Product: Visual Studio Code
Product Version: 1.40.2
Language: en

Call Stack
extension.bundle.js:324:65436extension.bundle.js:324:65436
Object.<anonymous> extension.bundle.js:1:434228
extension.bundle.js:1:432316extension.bundle.js:1:432316
n extension.bundle.js:1:432090
Object.t.callWithTelemetryAndErrorHandling extension.bundle.js:1:434146
DockerDebugConfigurationProvider.resolveDebugConfiguration extension.bundle.js:324:65364
extensionHostProcess.js:729:964extensionHostProcess.js:729:964
@philliphoff
Copy link
Member

philliphoff commented Dec 9, 2019

I can repro this; the immediate issue is our misunderstanding of (and a bit of VS Code inconsistency in) how VS Code indicates whether a task/debug configuration is being executed in a workspace context (vs. a folder context). In the case of debugging, VS Code passes undefined for the workspace folder. Our debug configuration provider should fallback to the root workspace folder in that case rather than failing with the above error. In the case of a task, VS Code passes the enumerated value TaskScope.Workspace for the scope rather than an actual workspace folder. Our task provider should, again, fallback to the root workspace folder in that case.

While those are relatively simple fixes, the larger issue is that, as of 1.40.2, VS Code does not appear to execute debug configurations defined as part of the workspace. (That is, VS Code will resolve them but execution fails without error or exception, for both .NET and Node.js adaptors.) This appears to be resolved in the 1.41.0 build of the VS Code Insiders edition. However, it appears there's still an issue with workspace-defined debug-configuration preLaunchTasks that we will likely have to wait for, as we rely on pre-launch property to perform the Docker build/run chain of tasks.

The current workaround would be to put the task/debug configuration in the .vscode/[launch|tasks].json files rather than the workspace .code-workspace file.

@dbreshears
Copy link
Member

@ravipal , after next VSCode release, please validate this is fixed and close

@dbreshears dbreshears modified the milestones: 0.10.0, 0.11.0 Jan 24, 2020
@ravipal
Copy link
Contributor Author

ravipal commented Feb 6, 2020

Now the error is different in VS code version 1.41.1
image

@dbreshears dbreshears assigned bwateratmsft and unassigned ravipal Feb 20, 2020
@dbreshears dbreshears added P1 and removed P2 labels Feb 20, 2020
@bwateratmsft
Copy link
Collaborator

@philliphoff the C# extension adds the tasks as workspace folder tasks irrespective of whether you have a workspace open. When we add the debug tasks, we're adding them as workspace tasks. The result is that it never runs dotnet build (because that task is defined somewhere other than workspace), doesn't show a warning or error that it didn't execute a dependent task (thanks VSCode), and fails at time of launch. I can't repro the new error @ravipal is seeing.

We should add the tasks as workspace folder tasks always.

@bwateratmsft
Copy link
Collaborator

bwateratmsft commented Feb 20, 2020

Update: if I move the dotnet build task down to workspace tasks, everything works. So we have three options:

  1. Always use workspace folder tasks/debug, never workspace tasks/debug
  2. Tell the C# extension they need to use workspace tasks/debug when a workspace is open
  3. Tell users who want to use workspace tasks/debug that they must move the dotnet build task

Related to the above, when I tried the right-click-Dockerfile > Build Image, our code successfully found and selected the official build task, but calling vscode.tasks.executeTask failed saying the task does not exist. So, I gather that API is not working for workspace tasks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants