Scott Hanselman

Running Microsoft Edge on Linux with WSLg while running Visual Studio 2019 and debugging a Linux .NET app with WSL on Windows 10

May 25, 2021 Comment on this post [2] Posted in VS2019
Sponsored By

How about that insane blog title?

You can do lots of cool things with WSLg, which allows you to seamlessly and cleanly run Linux apps on Windows. I've written about this before.

And you know that you've been able to run Linux server apps on Windows for a long time. There's even support in VS Code and VS2019 to debug those apps.

But how far can we take this? What about Debugging a .NET web app running under Linux while running Visual Studio 2019 for Windows and accessing that web app via a Linux Browser?

Why? Why the heck not? Seriously though, because choice and flexibility. If this solution isn't interesting to you, then perhaps you don't have this problem. But if you do have this problem, then here's the solution. Welcome!

Prerequisites

At some point soon, WSL and WSLg will be a part of the mainline of Windows, but at the time of this writing they are inside Windows 10 Insiders 21362+. Follow the instructions here to setup WSL2 and WSLg. This assume you're running a distro like Ubuntu.

Then add a browser like Edge for Linux or Chrome for Linux as below.

## Google Chrome
cd /tmp
sudo wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt install --fix-broken -y
sudo dpkg -i google-chrome-stable_current_amd64.deb

## Microsoft Edge Browser
sudo curl https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-dev/microsoft-edge-dev_91.0.852.0-1_amd64.deb -o /tmp/edge.deb
sudo apt install /tmp/edge.deb -y

You'll know they are working and installed when the Linux GUI apps show up in the Windows Start Menu.

Ubuntu GUI Apps

Adding a Linux Browser to Windows Visual Studio 2019

Open up Visual Studio 2019, and either open up or create a Web Application. From Debug button there's a dropdown (chevron) where you access this menu:

Browse With

Select "Browse With..."

From the Browse With dialog, you're going to add a new Browser, selecting "C:\Windows\System32\wslg.exe" as the Program and "~ -d Ubuntu /usr/bin/microsoft-edge-dev" as the Arguments. Ignore any errors.

Browse With, adding a Browser

You should see the new Browser inside Visual Studio 2019 now and can select it like any other browser.

Microsoft Edge under WSLg under Ubuntu

Boom. Here I am running my Podcast website under Linux on .NET 5 on the server-side AND on the client-side in the Edge Browser as a Linux GUI app!

Debugging Linux Edge GUI app under WSL2 inside Visual Studio 2019

Enjoy! And please watch the BUILD 2021 Application Development Keynote, I think you'll enjoy it.


Sponsor: Build your apps where your customers are. Oracle for Startups delivers enterprise cloud with no lock-in so you can go after any customer—confidently. Learn more.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
May 29, 2021 23:48
This makes x-plat development awesome on Windows. When pigs fly, can we finish the story and also please have WSM (Windows Subsystem for MacOs)?
June 03, 2021 12:38
I love wslg it let's accomplish so much things that would be nearly impossible without it. I also like that Microsoft is accommodating Linux - that's proper way to go.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.