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

VS Code extension, debugging: .cshtml files not found when at breakpoint #304

Closed
dougbu opened this issue May 10, 2016 · 4 comments
Closed

Comments

@dougbu
Copy link
Member

dougbu commented May 10, 2016

An Exception thrown within a view (or the code a view calls) correctly breaks execution. But the display shows neither the Razor-generated C# code nor the .cshtml source. It seems the C# extension does not support the project directory being the virtual root used in generated #line pragmas. The same code works fine in Visual Studio.
cshtml filenotfound

The above image is from a Windows system. The behaviour is the same on a Linux (Ubuntu 14.04 LTS) system except the slashes go in the opposite direction.

@gregg-miskelly
Copy link
Contributor

@wesrupert FYI I am assigning this to you

@wesrupert
Copy link
Contributor

This is a bug in Razor (#803) that we don't really have a good way to work around on our side. To work around it per-project in the meantime, please add a sourceFileMap to your launch.json configuration to redirect relative .cshtml paths to their absolute counterparts.

Windows:

"name": ".NET Core Launch (web)",
...
"sourceFileMap": {
    "/Views": "${workspaceRoot}\\Views"
}

macOS/Linux

"name": ".NET Core Launch (web)",
...
"sourceFileMap": {
    "/Views": "${workspaceRoot}/Views"
}

The next version of the extension will add this to projects automatically, as well as let you set breakpoints and view/set variables and watch expressions in .cshtml files.

@gregg-miskelly
Copy link
Contributor

@wesrupert can we use the forward slash version on Windows also? If not, we should fix it so that you can.

@wesrupert
Copy link
Contributor

@gregg-miskelly in the next version of the C# extension, yes. In the meantime, windows needs the backslash.

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

No branches or pull requests

3 participants