Search code examples
angulargoogle-chrome-extensionvisual-studio-2022

Visual Studio 2022 / Angular standalone - Preserve browser context


Unlike an Angular .NET Core project, stand-alone Angular projects do not preserve the browser context between two debugging sessions. Is there a way to force Visual Studio to launch the browser in non-private browsing ?

I'm working on a front application that uses a browser extension. Private Browsing forces me to install/configure the extension every time I launch a new debugging session.


Solution

  • Just add this configuration to file .vscode/launch.json:

    {
        "type": "chrome",
        "request": "launch",
        "name": "localhost (Chrome)",
        "url": "http://localhost:4200",
        "webRoot": "${workspaceFolder}",
        "runtimeArgs": [ "--user-data-dir=${workspaceFolder}\\.browserDir\\Chrome" ]
    }
    

    And create the .browserDir\Chrome folder in the solution directory.