At MVP Summit this year, one of the valuable things I learnt (which I can share ) was from Colin Dembovsky (ALM MVP) which was Using Chrome to Solve Identity Hell. Now I knew Chrome profiles existed but never thought of using them to solve the problem of different identities, in-private mode was a way of doing things but you always lost that when closing the session, so wasn't that great. Not going to talk much about that here, you can read this post to find out more.
So Chrome Profiles are Great, What Are We Trying to Fix?
As mentioned above Chrome profiles are great so what's been annoying me is maybe you (if you arrived here from a search )? The problem is that Visual Studio when set to use Chrome as the browser does exactly that and uses Chrome.
If you haven't had any issues with this, you might not have as many Chrome profiles open as I do . To explain this a bit better, when you close all instances of Chrome and then open Chrome again, the default Chrome behavior is to load the last profile you had open. You can change this by pinning specific shortcuts to the profile or having a desktop shortcut to that profile.
Why is this Frustrating?
Before it wasn't annoying because I always had auth issues so I would launch the project Ctrl + F5 and then immediately go into in-private mode (I know F5 gives you a similar experience but not always the desired running state or I would just log out of the accounts I usually use and then do some dev logging into test Microsoft accounts if need be and then later log myself out of there and back into my regular accounts. As you can imagine, this is slightly painful.
Now that I have the magic of profiles, I would launch the app and it would open default chrome which would open my last active profile which could land me in a similar space as before where I'm using my real MSA for example. At this point, I'd change the Chrome profile back to First User and then either re-browse to the app or go back to VS and ctrl + F5 and this would then use the First user profile to do my dev but still felt a little clunky.
So How Do We Change this in Visual Studio?
The way the shortcut works for Chrome is a parameter is passed on load specifying which profile to load, to view this:
- Right click on the Chrome shortcut (I have pinned mine to the taskbar already)
- Right click on the name of the Chrome profile shortcut
- Click on Properties
This will open the properties for the shortcut where you will notice the --profile-directory parameter being passed into the chrome.exe executable.
Copy the full target as we'll use both parts next. Open up a web project in Visual Studio and:
- Click on the little down arrow next to the Start Debugging menu
- Click on Browse with...
This will bring Browse with dialog where we will now click on Add...
In this dialog, we are going to paste the Target we copied from the properties window, remove the quotes around the path to chrome.exe and then cut the parameter part to the arguments section and give the browser and friendly name and click OK.
This will add the browser to the overall list of browsers you have. If you are like me and want a consistent feel to launching sites, then you'd probably want to make this browser your default.
All set to have a pain free browsing experience when doing your development .
This now means that I can log into this dev profile that I have created and that account will always be logged in, if I have a Twitter, Facebook, MSA, anything account the cookies and all settings extensions are saved to that profile. You can roam this by signing into Chrome with a development Google account if you want to make your config, remembered uris and passwords (not generally a good idea, but love this for dev environments roam to all your machines easier.
Most importantly, each time I launch from VS now, I know what environment state I'm going to get.
Visual Studio and a lot of other tools like Chrome (yes the browser is a dev tool too ) have a lot of features that are less commonly used that can make your development experience less frustrating and ultimately more productive. You just need to look for them sometimes and think a little outside the box on how you can use them .
If you have any other similar or related productivity tips, please feel free to share them.