{
"$type": "site.standard.document",
"canonicalUrl": "https://johnnyreilly.com/posts/debugging-aspnet-core-in-vs-or-code",
"description": "Learn how John became a fan of VS Code for TypeScript and how they managed to debug ASP.Net Core using the extension for C#.",
"path": "/posts/debugging-aspnet-core-in-vs-or-code",
"publishedAt": "2017-03-28T00:00:00.000Z",
"site": "at://did:plc:yy3apqjlms24kso7ahn7lbmb/site.standard.publication/3mova7c4nho2b",
"tags": [
"vs code",
"visual studio",
"asp.net"
],
"textContent": "I've been using Visual Studio for a long time. Very good it is too. However, it is heavyweight; it does far more than I need. What I really want when I'm working is a fast snappy editor, with intellisense and debugging. What I've basically described is VS Code. It rocks and has long become my go-to editor for TypeScript.\n\n\n\nSince I'm a big Cfan as well I was delighted that editing Cwas also possible in Code. What I want now is to be able to debug ASP.Net Core in Visual Studio OR VS Code. Can it be done? Let's see....\n\nI fire up Visual Studio and File -> New Project (yes it's a verb now). Select .NET Core and then ASP.Net Core Web Application. OK. We'll go for a Web Application. Let's not bother with authentication. OK. Wait a couple of seconds and Visual Studio serves up a new project. Hit F5 and we're debugging in Visual Studio.\n\nSo far, so straightforward. What will VS Code make of this?\n\nI cd my way to the root of my new ASP.Net Core Web Application and type the magical phrase \"code .\". Up it fires. I feel lucky, let's hit \"F5\". Huh, a dropdown shows up saying \"Select Environment\" and offering me the options of Chrome and Node. Neither do I want. It's about this time I remember this is a clean install of VS Code and doesn't yet have the Cextension installed. In fact, if I open a Cfile it up it tells me and recommends that I install. Well that's nice. I take it up on the kind offer; install and reload.\n\nWhen it comes back up I see the following entries in the \"output\" tab:\n\nNote that mention of \"debugger\" there? Sounds super-promising. There's also some prompts: \"There are unresolved dependencies from 'WebApplication1/WebApplication1.csproj'. Please execute the restore command to continue\"\n\nSo it wants me to dotnet restore. It's even offering to do that for me! Have at you; I let it.\n\nThe other prompt says \"Required assets to build and debug are missing from 'WebApplication1'. Add them?\". This also sounds very promising and I give it the nod. This creates a .vscode directory and 2 enclosed files; launch.json and tasks.json.\n\nSo lets try that F5 thing again... http://localhost:5000/ is now serving the same app. That looks pretty good. So lets add a breakpoint to the HomeController and see if we can hit it:\n\nWell I can certainly add a breakpoint but all those red squigglies are unnerving me. Let's clean the slate. If you want to simply do that in VS Code hold down CTRL+SHIFT+P and then type \"reload\". Pick \"Reload window\". A couple of seconds later we're back in and Code is looking much happier. Can we hit our breakpoint?\n\nYes we can! So you're free to develop in either Code or VS; the choice is yours. I think that's pretty awesome - and well done to all the peeople behind Code who've made this a pretty seamless experience!",
"title": "Debugging ASP.Net Core in VS or Code"
}