Scott Hanselman

Can you really develop with Linux GUI Apps on Windows 10 with WSLg? How about PyCharm?

April 22, 2021 Comment on this post [3] Posted in Linux | Win10
Sponsored By

I blogged about How to run Linux GUI apps on Windows 10 with WSL and WSLg, but how "real" is this? Are these just toy apps? Nope.

I wanted to see if I could install the Community Edition of PyCharm on Ubuntu 20.04. Even though I can't use "snaps" yet on WSL (because of systemd support in progress) I can easily just get the tar file, untar it, and run it and it works.

I did a wget of the standalone, then tar xzf'ed into a folder and ran pycharm.sh and it literally just worked.

When debugging I did get an "unable to execute x86_64-linux-gnu-gcc" error but that's just because I hadn't setup build-essentials yet. Once I installed the right stuff I was all set.

sudo apt-get install build-essential autoconf libtool 

Cool looking, eh?

Linux PyCharm on Windows running under Ubuntu 20.04 with WSL and WSLg

I prefer to do most of my Linux dev using VSCode Remote but there's a TON of options here now that you can run Windows apps, Linux apps, or split-brain apps with half inside Linux and half in Windows. Amazing stuff!

VS Code Remote Architecture

You can learn about WSLg over in their GitHub, it's all open source.


Sponsor: Extend your runway and expand your reach. Oracle for Startups delivers enterprise cloud at a startup price tag with free cloud credits to help you reel in the big fish—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

How to run Linux GUI apps on Windows 10 with WSL and WSLg

April 21, 2021 Comment on this post [5] Posted in Linux | Win10
Sponsored By

Many folks have installed X servers and X410 on their Windows 10 machines and hacked together very nice X Server set ups with WSL over the years. However, that support is now official and coming to Windows very soon. It's already in Windows 10 Insiders Dev and is in builds 21364 or higher. (Run winver to see what version of Windows you have.)

If you want to try it out, all you have to do is run "wsl --update" from and command line and you're set. If you have 21364 already but you don't have WSL installed, it's even easier to get started now. (Full details on GitHub as the whole thing is open source as well!)

wsl --install -d Ubuntu

The best part of all this is that you just install Linux GUI apps in your distro with apt install like you would already, and they'll show up automatically in the Windows Start Menu!

Linux GUI apps running from Start Menu

Even better, if you have a nice GPU, you can run WSLg on a system with virtual GPU (vGPU) enabled for WSL so you can benefit from hardware accelerated OpenGL rendering. You can find preview driver supporting WSL from each of our partners below.

Here's the Dolphin Emulator running on my Surface Book 3 laptop on the NVidia vGPU at ~60 fps.

Dolphin on WSL under Windows 10 running at 60fps

You can even run Chrome, Edge, or Teams under Linux on Windows 10 with WSLg.

This is more than just X Server support. The community is moving towards Wayland as a simpler X, but there's also Weston to consider as a great compositor to build on. Weston already had a RDP (Remote Desktop Protocol) backend and could use with with FreeRDP. But windows already has Windows Virtual Desktop that uses RDP RAIL (Remote Application Integrated Locally) as well as VAIL (Virtualized Application Integrated Locally) for optimizing transport over VM (local) boundaries vs network ones. There's an amazing blog post on WSLg Architecture here by Steve Pronovost.

diagram-description-automatically-generated

All this means more than just X apps, WSLg works with OpenGL apps and works amazingly on systems with a GPU that supports WDDMv3.0. The preview drivers linked to above will eventually ship in Windows Update automatically when all this is generally available.

Finally, interesting stuff is cooking at Canonical (Ubuntu) with their custom WSL2 specific distro for Ubuntu on Windows! It's in preview for now:

The Ubuntu on Windows Community Preview will only be available through this link to the Microsoft store. You will not be able to find the Community Preview just by searching in the Microsoft Store.

And finally, here's some answers to some of your "ya but you can do THIS?" questions about running Linux GUI apps on Windows 10.

Can you run The Gimp under WSLg?

Yes. Do know that things in WSLg look best under round number DPI scaling. I'm at 200 here. It'll look back at 175% or something fractional unless you explicitly turn on WESTON_RDP_DISABLE_FRACTIONAL_HI_DPI_SCALING=true in your /mnt/c/ProgramData/Microsoft/WSL/.wslgconfig. But trust me, stay with round numbers.

EzndJavUYAErYqb

Can you run Wine (Wine Is Not an Emulator) to run Windows under WSLg under Linux under Windows?

Absolutely. Here I'm running Internet Explorer (after installing Gecko) under Wine under WSL in Ubuntu on Windows. Why not?

EznjLMtVgAA3oeP

How fast is it? Here I'm running Windows 3.1 emulated within Javascript using PCJS under WSLg within Edge for Linux on Windows 10. It's very fast.

EznlBT0VkAIQD3W

Does PulseAudio work?

Totally does. Out of the box. The genius of the architecture is that there's an already setup WSLg System Distro (this means it's more robust and you can't mess up the settings and accidentally break something) that has everything prepped and working.

Conclusion

If you don't like this or you think this is silly to you, then you likely don't have a problem that this solves for you. For me, this just makes my Windows machine an amazing Linux desktop on top of being a great Windows 10 desktop machine, without the overhead or hassle of a Linux VM. WSLg will let you run other IDEs such as gedit, JetBrains based editors, gvim, etc., to test, build, and debug your Linux applications in a high performance manner. You can also run VS Code on Windows like I do and use VS Code Remote to talk to WSL/Linux.

Go read about WSLg and check it out for yourself! Also be sure to check out the work that Pengwin Linux and the folks at Whitewater Foundry are doing as their distro works with WSLg out of the box already!


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

Converting a 13 year old .NET WPF app called BabySmash to a self-contained .NET 5 app with the .NET Upgrade Assistant

April 08, 2021 Comment on this post [0] Posted in BabySmash | DotNetCore
Sponsored By

13 years ago I wrote a .NET 3.5 WPF application for my then 2 year old baby/toddler. Maybe he was 18 months. He was small. He now wants to drive. https://www.babysmash.com/ continues to be a thing, even today. Recently "Chris The Meme God" had a 20 million view TikTok featuring BabySmash...where he failed to mention the URL. Sigh.

Anyway, the code has been up at http://github.com/shanselman/babysmash for years and other than a few small fixes, really hasn't been touched in 4 or 5 years.

Until Cathy Sullivan from the .NET team used BabySmash as a test application to upgrade to .NET 5 in the year 2021. She used the .NET Upgrade Assistant. She even LIVE STREAMED the upgrade process!

image

Cathy sent me a PR and we put the resulting .NET 5 BabySmash application in a new dotnet5 branch at https://github.com/shanselman/babysmash/tree/dotnet5. I'd encourage you to check it out as it's very easy to build now.

Make sure you get the dotnet5 branch and "dotnet build" from there, not the main branch.

The version that Cathy sent me built great in Visual Studio but had a small issue when building from the command line. Fortunately Alex Elia followed up with a PR of his own that enabled BabySmash to cleanly build from the command line with just the .NET 5 SDK.

He said:

I wasn't readily able to find artifacts for the .NET 5.0 version of BabySmash, so I made a pull request against the repository with a continuous integration pipeline, updated README and adjustments to enable using the .NET CLI for build/run/publish workflows. 

https://github.com/shanselman/babysmash/pull/25

It was a project property [that prevented it from building from the command line.] The .NET CLI targets one version of MSBuild whereas Visual Studio/devenv.exe targets another. There was one particular property, GenerateManifests, in the csproj that the .NET CLI version of MSBuild rejected.

The property GenerateManifests being set to true chain triggers down to a call to MSBuild for a task FormatUrl (https://docs.microsoft.com/en-us/visualstudio/msbuild/formaturl-task?view=vs-2019) which is fairly intuitively named; It formats a URL. The .NET CLI version of MSBuild does not support this task and thus rejects the build.

Interesting note on why it was difficult to find this. WPF projects trigger a build task called MarkupCompilePass1 (https://docs.microsoft.com/en-us/visualstudio/msbuild/markupcompilepass1-task?view=vs-2019) to process the xaml/cs views files into generated .g.cs and baml files. If the build failed due to the GenerateManifests error then that dotnet.exe process would hang and subsequent builds will fail due to a collision on the WPF .g.cs generated files. 

Fantastic! I followed up with this small tweak to the "dotnet publish" command line which allows us to now to make a single babysmash.exe file that includes the whole app and .NET, with NO INSTALL.

dotnet publish --configuration Release --runtime=win10-x64 --output ./publish -p:PublishReadyToRun=true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained=true -p:DebugType=None

You can get the babysmash.exe from https://github.com/shanselman/babysmash/releases/tag/dotnet5-v0.1 if you'd like, or just install the old one from http://www.babysmash.com!


Sponsor: Extend your runway and expand your reach. Oracle for Startups delivers enterprise cloud at a startup price tag with free cloud credits to help you reel in the big fish—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

Take your Windows Terminal and PowerShell to the next level with Terminal Icons

April 06, 2021 Comment on this post [32] Posted in Win10
Sponsored By

I'm having a blast customizing my terminal and making my prompt awesome.

I thought it was lovely when I added Oh my Posh 3. But now that I've seen Kayla Cinnamon's terminal MINE IS HIDEOUS!

Windows Terminal Pretty Prompt

Ok, what can we add? MOAR ICONS.

Turns out that Brandon Olin from StackOverflow has created a Terminals Icons package that is *chefs kiss*. Go give this man 1000 stars, please.

Given I'm using the completely overpowered "caskaydiacove nf" Nerd Font Variant of the lovely Cascadia Code font, I've got all the icons I need ready to go!

I just install. (I'm using PowerShell 7 from the Windows Store, but remember PowerShell is cross platform):

PS> Install-Module -Name Terminal-Icons -Repository PSGallery

And then add one line to my $profile (edit with "code $profile"):

Import-Module -Name Terminal-Icons

Now look at a directory, use dir, ls, or get-childitem, it doesn't matter...AND BEHOLD:

Lovely PowerShell with Directory Icons

Thanks Brandon and Kayla! Great stuff! What customizations have YOU made?


Sponsor: Extend your runway and expand your reach. Oracle for Startups delivers enterprise cloud at a startup price tag with free cloud credits to help you reel in the big fish—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

How to make Command Prompt, PowerShell, or any Shell launch from the Start Menu directly into Windows Terminal

March 25, 2021 Comment on this post [11] Posted in Win10
Sponsored By

I love the Windows Terminal, but right now I launch the Terminal, then I pick a Shell (PowerShell, CMD, bash, etc) from the menu. Sometimes I want to be "shell-first."

I'll hit the Start Menu, type cmd, and then the older console/terminal starts up. I have to remember to run Terminal THEN run cmd. So I said to myself, "self, what's a good way to fix that?"

When you press Start and start typing (which is different from WinKey+R and running a .exe directly) you're looking at Shortcuts/LNK files. You can make your own and change existing ones.

Press Start, type "Command Prompt" or "PowerShell" and then RIGHT CLICK the icon and Open File Location.

PowerShell in the Start Menu

For example, Command Prompt was here on my machine:

C:\Users\scott\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools

So I Ctrl+C, Ctrl+V to make a copy (backup) or I can just right click and hit properties to change the one I have.

Then I change the Target to wt.exe (Windows Terminal) and pass in the Named Profile for the Shell I want:

C:\Users\scott\AppData\Local\Microsoft\WindowsApps\wt.exe -p "Command Prompt"

In this case, it's Command Prompt. I also renamed my LNK file to Command Prompt (Terminal) but that's optional.

Command Prompt in Terminal

I can do the same thing for PowerShell. I've moved to open source PowerShell 7 (based on .NET Core) that I installed from the Windows Store.  Some store apps don't want you to change their icons so I just changed another. You can also make your own with right-click, New Shortcut.

PowerShell in Terminal

I even did this with the Visual Studio 2019 Developer Prompt by first making a Profile for it in my Terminal settings:

{
"commandline": "C:\\WINDOWS\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe -noe -c \"&{Import-Module \"\"\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\Tools\\Microsoft.VisualStudio.DevShell.dll\"\"\"; Enter-VsDevShell 4f53a196}\"",
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff45ce}",
"hidden": false,
"name": "VS2019 Dev Prompt",
"startingDirectory": "%USERPROFILE%"
},

and then changing the icon to call it with wt.exe and the named profile. This can also work with Cygwin, Yori, Ubuntu, or any other shell.

A few minutes and a few shortcut changes later, now I can hit start, type PowerShell, command, cmd, whatever, and it'll all load in Windows Terminal!

Windows Terminal for All

Since this technique works only with lnk files that the Start Menu consumes, it also works with PowerToys Run (which is like Quicksilver or Spotlight on Mac)!

PowerToys Run is like Quicksilver for Mac

Hope this helps!


Sponsor: The No. 1 reason developers choose Couchbase? You can use your existing SQL++ skills to easily query and access JSON. That’s more power and flexibility with less training. 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

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