4

I'm working through an Angular course via Visual Studio 2019 and Google Chrome (same thing happens in the New Edge).

Running F5 in Visual Studio brings up the website with rebuild/refresh on save. Great! The problem I have is it auto-switched to sources.

Can I disable the auto-switch to sources so it stays in Console like I want it too? It's real annoying to only want the Console yet always get kicked to sources.

enter image description here

Animated Gif

Edit: Specs of machine. Ask for more if needed.

  • Windows 20H2 updated as of yesterday.
  • Edge: Version 87.0.664.47 (Official build) (64-bit)
  • Chrome: Version 86.0.4240.198 (Official Build) (64-bit)
  • Visual Studio Enterprise 16.8.2.
WernerCD
  • 2,137
  • 6
  • 31
  • 51
  • 1
    I hate this too and I've never been able to figure it out. Anytime your app reloads the chrome debugger goes nuts (breaking in places you don't want it to/jumping to different tabs/etc..). From my research, it has something to do with the chrome browser being opened in incognito/without the user profile. I assume the magical setting is deep in the user profile somewhere. – mwilson Nov 26 '20 at 01:26
  • ... I'd recommend checking out WebStorm and just not using the chrome dev tools unless you absolutely need it. Most of the debugging capabilities in WebStorm are far superior than browser dev tools. – mwilson Nov 26 '20 at 01:27
  • 1
    I made a test with the Visual Studio 2019(Version 16.6.2) and MS Edge browser(Version 87.0.664.47). I create an ASP.NET Core web application project with Angular and try to run it using the F5 key. App gets launched in the Edge browser and I open the developer tools and move to the console tab. Then after I made some changes in the app and save it. Based on my test result, I found that the console stays there and tab not get move to the sources tab. Let us know which VS and Edge version you are using for making this test? Also, let us know if we have missed any step while producing this issue. – Deepak-MSFT Nov 26 '20 at 02:15
  • @mwilson first time digging into angular (on vacation, no less) and first time noticing it. – WernerCD Nov 26 '20 at 03:03
  • As far as Webstorm... you mean instead of Visual Studio? or VSCode? Does it show console.log as well or are you saying it's a better environment all around? I do have a jetbrains sub – WernerCD Nov 26 '20 at 03:04
  • @Deepak-MSFT that's basically all I'm doing... in edge and chrome. I'm logged into Chrome but not Edge. I use chrome on the daily but Edge only for testing - to get the same result. OS is up to date, as is chrome. Chrome? "Version 86.0.4240.198 (Official Build) (64-bit)". Edge: "Version 87.0.664.47 (Official build) (64-bit)". I could see if I can take a small video (animated gif?) if it comes down to it. – WernerCD Nov 26 '20 at 03:08
  • @Deepak-MSFT animated gif uploaded... went greyscale for size. Direct Link: https://thumbs.gfycat.com/FamousSeparateAnkolewatusi-mobile.mp4 – WernerCD Nov 26 '20 at 03:45
  • https://i.imgur.com/pZNT8zC.gif - got the good one uploaded to imgur. You can see me F5, opens window... switches to Sources as "new files" get uploaded during "updates". – WernerCD Nov 26 '20 at 03:56
  • @mwilson Followup: If I do the server via Webstorm or via cmd "ng serv", it doesn't "spaz out". It's got to be something with the way Visual Studio serves it up... the default project for Angular in 2019 includes Asp.net Core WebAPI for backened (not using it currently, but I might)... So this is definitely something to do with Visual Studio-Chrome interaction and not Angular. – WernerCD Nov 26 '20 at 04:57
  • @WernerCD, Can you please inform us the version of the Edge browser? It can help us to make a test with that specific version. If you are not using the stable version of the Edge browser then I suggest you also try to make a test with it and see whether it is working properly or not. – Deepak-MSFT Nov 26 '20 at 05:22
  • @Deepak-MSFT answered in a previous comment: Edge: "Version 87.0.664.47 (Official build) (64-bit) – WernerCD Nov 26 '20 at 05:38
  • @Deepak-MSFT I can even roll a version of the build into a git commit if you need. But Windows 20H2 updated as of yesterday. Edge, updated as of yesterday (version 87 as mentioned). Chrome: Version 86.0.4240.198 (Official Build) (64-bit). Visual Studio Enterprise 16.8.2. – WernerCD Nov 26 '20 at 05:39
  • Okay... I'm plugging around trying different things as I was getting ready to create a GIT repo with the problem. And I stumbled across the cause even if I'm not sure what the ROOT root cause is: .vs folder. When I delete the solution\.vs folder the problem goes away. Something in that folder is causing the problem. – WernerCD Nov 26 '20 at 06:36
  • So I have no clue what's in the .VS-Bad folder... but a clean .vs folder solves the issue... I move the bad .vs folder back and the problem returns. – WernerCD Nov 26 '20 at 06:41
  • @mwilson just found that clearing the .vs folder removes my issue... you say you have the same problem? Maybe you'll have the same solution? – WernerCD Nov 26 '20 at 06:41
  • 1
    Thanks for sharing the solution to the issue. I suggest you post your solution as an answer for this thread and try to mark your own answer as an answer to this question after 48 hrs when it is available to mark. It can help other community members in the future in similar kinds of issues. Thanks for your understanding – Deepak-MSFT Nov 26 '20 at 06:43
  • @Deepak-MSFT Absolutely... I was just doing some final toying before I did so. The project is relatively new and the OS was cleaned not long ago either so everything should be pristine. Never would have thought to clear out the .vs folder and only accidentally did so when creating a new project. – WernerCD Nov 26 '20 at 06:44
  • @WernerCD Yea, WebStorm is just a JavaScript-centric IDE so it comes with all kinds of bells/whistles that are specific to modern front-end/back-end setups within JavaScript. That's odd you're only seeing the issue happen in VS. I have been using WebStorm for the past 5 years or so and have been experiencing this issue consistently. JetBrains just told me that it had something to do with the way chrome is launched without a user profile. In any case, glad you found a fix. – mwilson Nov 30 '20 at 17:41
  • @mwilson Yeah, not sure what is causing the problem under the hood - and it just happened again. Visual Studio has a .vs file under the project directory which houses project settings ( https://stackoverflow.com/questions/48897191/what-is-the-vs-folder-used-for-in-visual-studio-solutions ). Change something => Chrome goes janky... close visual studio > delete .vs > reopen project > change something > it stays on Console when ng detects change and rebuilds. You still have the problem in JetBrains? or was it only in Visual Studio? – WernerCD Nov 30 '20 at 19:31
  • 1
    If you are using the third-party extensions with Visual Studio then just for testing purposes, try to disable/ remove them. If possible then try to use `devenv /safemode` to start VS. You can also try to reset the Visual studio to its default settings and check whether it helps to fix the issue. – Deepak-MSFT Dec 02 '20 at 09:20

2 Answers2

14

I had the same issue and it was driving me nuts! The way I managed it to stop switching was to go to into the DevTools settings -> Preferences.

Under Sources options, uncheck Focus Sources panel when triggering a breakpoint.

A. Johan
  • 366
  • 2
  • 6
-4

After much testing and toying around, the issue was solved by removing the .vs folder in the solution folder.

A clean .vs folder is created and the problem disappears.

Returning the "bad" .vs folder returns the issue.

WernerCD
  • 2,137
  • 6
  • 31
  • 51
  • @CodeMan03 Well, not for nothing... it's been a few years since I asked and then answered my own question with what solved my personal issue. What kind of answer is this? It's the answer that worked... there's a folder called .vs that removing made it get regenerated, fixed and worked. I asked and answered the next day. Is my answer to my question not acceptable somehow? – WernerCD May 10 '23 at 17:47