That's C# 9 top level programs. We should be able to remove even more. Skip the first command completely and do it all on one line, one file.
A hello world is either
using System;
Console.WriteLine("Hello World!");
or
System.Console.WriteLine("Hello World!");
or, scandalously
using System;
using static System.Console;
WriteLine("Hello World!");
Not sure how I feel about that last one. Regardless...would this work in Visual Studio 2019? What if I was teaching a class and wanted to have one file per homework assignment, for example? Right now Visual Studio only supports one top-level program per project. Make sense why, but for learning, why not allow folks to choose from the run/debug menu?
I'm going to add a reference to SmallSharp like this (or in Visual Studio)
> dotnet add package smallsharp
Now here's what my homework looks like in Visual Studio 2019! There's one menu item per top level program!
This lovely prototype was done by Daniel Cazzulino (kzu) and you can learn more at https://github.com/devlooped/SmallSharp, or just try it out as I have here!
What do you think? How can small top-level programs help new people?
What about this?
> dotnet new microservice
> dotnet run
Sound off in the comments. How tight and simple would that be?
Sponsor: Tired of not finding the code you're looking for? Get Sourcegraph universal code search and search code across ALL your repos, languages, and code hosts. Find and fix code fast with Sourcegraph. Try it now!
This is pretty cool. As you may know, when you type "dotnet new" from the command line, or if you turn on the Visual Studio preview feature "Show all .NE Core templates in the New Project Dialog" that you see a bunch of potential starter templates. These are basic jumping off points for your next new project.
Some folks feel there should be more included "out of the box." Enter "dotnet-boxed" templates! You can install them from the command line easily like this:
dotnet new --install Boxed.Templates
You can confirm they are there by running dotnet new at the command line. The new "boxed" templates have a different tag:
Templates Short Name Tags
----------------------------------------------------------
ASP.NET Core API Boxed api .NET Boxed/Cloud/Service/Web
ASP.NET Core GraphQL Boxed graphql .NET Boxed/Cloud/Service/Web
ASP.NET Core Orleans Boxed orleans .NET Boxed/Cloud/Service/Web
NuGet Package Boxed nuget .NET Boxed/Library
Let's try them out! I can see them here in the File New Project dialog in VS2019:
There's a really nice project that sets up a NuGet package right from File New! It can even set up Test, GitHub Actions, .editorconfig, license, cake build, code of conduct, and more. All that boring boilerplate is done for you!
This is just one template example, there are also ones for WebAPIs, GraphQL projects, and Microsoft Orleans projects.
DotNet-boxed is a great community supported project! Head over to GitHub now and give them a STAR and get involved! Even better, I see some "help wanted" issues on their GitHub. I'm sure they'd appreciate your help. https://github.com/Dotnet-Boxed/Templates
Sponsor: Tired of not finding the code you're looking for? Get Sourcegraph universal code search and search code across ALL your repos, languages, and code hosts. Find and fix code fast with Sourcegraph. Try it now!
"Dapr helps developers build event-driven, resilient distributed applications. Whether on-premises, in the cloud, or on an edge device, Dapr helps you tackle the challenges that come with building microservices and keeps your code platform agnostic."
I've had Mark Russinovich on my podcast recently to talk about Dapr which is now at version 1.0. Dapr is platform agnostic, and you can use Dapr with your language of choice by leveraging an SDK or making simple HTTP or gRPC calls. Dapr is language agnostic and can run on any hosting environment including local development machines, Kubernetes, and public clouds such as AWS, Azure and GCP. The Dapr sidecar container collects traces so your application is instrumented with no additional code.
This free book covers common needs for complex cloud apps and how to make it happen with Dapr and .NET, including:
State management
Service invocation
Pub/sub
Bindings
Observability
Secrets
Dapr .NET SDK
and more.
Dapr enables developers using any language or framework to easily write microservices. It addresses many of the challenges found that come along with distributed applications, such as:
How can distributed services discover each other and communicate synchronously?
How can they implement asynchronous messaging?
How can they maintain contextual information across a transaction?
Hope you enjoy it! The team would really hard on making it happen.
Sponsor: Have what it takes to code securely? Select from dozens of complimentary interactive secure coding labs, test your skills, and earn a badge. Learn more!
Visual Studio Community IS effectively the Pro SKU and is free for Open Source. You may even have a "Take Home" license at your work since the paid version of VS is licensed per-user, not per-machine, so ask your boss if you can install it at home and get the same pro tools you use at work.
Visual Studio 2019 with the UWP, .NET desktop, and Azure workflows enabled and also includes the Windows Template Studio extension
Visual Studio Code
Windows Subsystem for Linux enabled with Ubuntu installed
Developer mode enabled
These are for eval or quick testing and expire regularly, so check back to get another if you need to. (BTW there are also free VMs for testing IE11 or Edge Legacy but we don't talk about those.)
Again, VS Code is free for Windows, Mac, and Linux, and VS itself is free for Windows and Mac so you may not need these VMs, but knowing there are Windows developer VMs available free for eval is a super useful way to bootstrap development on any machine. Enjoy!
Sponsor: Have what it takes to code securely? Select from dozens of complimentary interactive secure coding labs, test your skills, and earn a badge. Learn more!
Sometimes blogging means lots of long form essays that take weeks to write and drop lots of wisdom.
However, many times blogging is just keeping track of a fix for a nagging problem. There may just be 5 or 6 of us with this issue, but if you're that person, this blog post is for you! Welcome to the solving of the issue you just googled for.
I recently bought an Elgato Key Light, and when I purchased it I did not realize that it did not have any external controls. You can only control the light with Wi-Fi and remotely. Personally I think that's a product flaw, this means I'm always going to have to be dependent on their software, and I can't just turn the thing to another level or color with a button.
The biggest issue with this light - and other picky IoT devices - is that it doesn't like my network. It happens to be the one and only device on my Ubiquiti network that doesn't seem to want to get along with the others in the house. It uses multicast DNS in the form of Apple's weirdo Bonjour service to broadcast itself, and it's notoriously hard to get the Elgato Control Center software to find the light. I know it's on the network, I can see its IP.
There's lots of blog posts with folks trying to solve this issue, and if you found your way to this blog post I figure that you've already done the obvious things like opening the firewall, turning on multicast DNS at the router level, and now you're just sick of it.
Here's my brute force solution that made my Key Light show up in Control Center.
First, I'm assuming a few things:
That you got the Elgato Key Light on to your network and you can find its IP Address.
That you installed the Elgato Control Center software on your PC
I put my Settings.xml file in this gist but the salient points are the SerialNumber and the IpAddress. You'll find the Serial Number on a sticker on the back of the light. You'll find the IP address in your router's IP table.
To be clear, this doesn't excuse not having buttons, but it's a start. Hope this helps both of you with this problem I had!
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.
Late last year I blogged about the Elecrow CrowPi2 Raspberry Pi Laptop. The folks at Elecrow are great and I've used their original CrowPi many times with the kids at and talks. None of these links are affiliate links and I am getting no kickbacks from the company - I'm just a fan and own two of their products.
As such I was excited to see their new Kickstarter called CrowBits. These are magnetic, programmable, electronic blocks that are also LEGO element compatible, which as you likely know, is a huge plus for my family. I've blogged a lot about STEM toys before, usually at Christmas, but this is a lovely spring surprise!
The devices are ESP32, Arduino and Micro:bit compatible, and there's over 80 of them. 30 of them need no programming. The whole system has a Scratch 3.0 software sitting on top, so my kids and I are already familiar with how to program these. If you're not familiar, MIT's Scratch is a visual block language that abstracts away the text aspects of programming for visually nested blocks. It's very intuitive.
Since the people at Elecrow have successfully delivered on all their previous KickStarters and I'm personally holding both CrowPis from those Kickstarters, I have high confidence in their ability to deliver the CrowBits.
Even better, I'm seeing in the comments on the Kickstarter that the company is aiming to allow their programming system to run on the Raspberry Pi CrowPi devices I already own, so that's a bonus that it'll all work together.
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.
Why have I been sleeping on the GitHub CLI? - there's a command line interface for GitHub!
I installed with "winget install GitHub.cli" but you can get it from https://cli.github.com if you like.
Then you run gh auth login once:
gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser
Now you've got a new command "gh" to play with!
I went over to one of my local git clones for the Hanselminutes Podcast website and I can now list the open Pull Requests from the command line!
Here's the real time saver that Dan Wahlin reminded me about: gh repo create!
> git init
Initialized empty Git repository in D:/github/ghcliblogpost/.git/
> gh repo create
? Repository name ghcliblogpost
? Repository description This is a test for my GH CLI Blog post
? Visibility Public
? This will add an "origin" git remote to your local repository. Continue? Yes
✓ Created repository shanselman/ghcliblogpost on GitHub
✓ Added remote https://github.com/shanselman/ghcliblogpost.git
Fantastic! You can even gh issue create!
gh issue create
Creating issue in shanselman/hanselminutes-core
? Title This is a test issue
? Body <Received>
? What's next? Submit
https://github.com/shanselman/hanselminutes-core/issues/219
Sponsor: Protect your apps from reverse engineering and tampering with PreEmptive, the makers of Dotfuscator. Dotfuscator has been in-the-box with Microsoft Visual Studio since 2003. Visit preemptive.com/hanselminutes for a professional-grade trial.
I've long run a few dozen websites in Azure and while I've long noticed people (frankly) wasting money by having one Azure App Service (a Web Site) per Azure App Service Plan (a VM) I tend to pack them tight.
A Basic 1 (B1) Azure App Service running Linux is around $13 a month but has nearly 2 gigs of RAM. Up that to about $26 a month and you've got 3.5 gigs of RAM and 2 Cores AND 10 gigs of storage. Use ALL that RAM. Max out that storage - use the resources you have paid for. If you hit up against a limit you can always add more and scale up. Run those boxes hot, you paid for them!
While my blog and podcast and main site run on Azure Premium SKUs (and are fast and it's worth it) I have a dozen little one pagers, brochureware sites, and toys like https://www.keysleft.com/ and I've managed them all in an App Service as well. But they are static sites. They are nothing sites...so why do I need an App Service? It's overkill.
As it's in Preview now it's free, and I'm sure it'll be super cheap when it goes live. I have no idea how much it will cost but I'll worry about that later. For now it's allowed me to turn off an entire Azure App Service and replace it with Azure Static Web Apps.
Check it out, I suspect you have a site right now that's either generated or just static and this could save you some money.
Sponsor: Protect your apps from reverse engineering and tampering with PreEmptive, the makers of Dotfuscator. Dotfuscator has been in-the-box with Microsoft Visual Studio since 2003. Visit preemptive.com/hanselminutes for a professional-grade trial.
My mom is very clever and thoughtful and when I was in my early teens and easily overwhelmed and generally freaking out or panicky she'd say, "feel it. Be here. What is your body telling you. Freak out fully but put a time limit on it."
This idea of "time-boxed freak outs" has always stuck with me. A few times a year I get overwhelmed. I think we all do to some extent. Often I'd try to fight it, don't cry, don't get overwhelmed.
But I remembered what my Mom said and I started being present in the freak out. I'd set a timer for 10 or 15 minutes and REALLY own it. Get upset, cry, and not feel bad about it.
I deserve the release and by time-boxing it, it allowed me to own it and accept it. I can ramp up, and then ramp down. I've found this to be far more healthy than trying to swallow feelings and hold it in. Sometimes it needs to be OK to go and cry in your car in the parking lot.
Disclaimer: I am not a doctor. I'm a random person and this is my random blog. This advice works for me and has worked for others, but know yourself and talk to a therapist if you are having uncontrollable panic attacks or feel unsafe. If this doesn't sound helpful, be present and be safe.
I tweeted about this idea and found a number of replies that also found this technique helpful. Here are some anonymized quotes:
“time boxed panic” I love it. Don’t skip the feelings. You can’t. You just defer them often to disastrous results. Sit with the discomfort a while. The way out is through.
and
Great advice. For some reason, we have been taught to suppress emotions, not to let things get to us and to not panic. And unfairly, men in particular have been encouraged not to show emotion. But it is a natural human response. Give yourself permission to feel & time box it.
and
This is a phenomenal idea. I would add, if you could add a few more minutes, take a walk away from whatever is stressing to clear your head. Sometimes being away from what is causing the stress can help as a reset.
and finally
You don't even have to cry or freak out. Just give yourself a time box to sit, stare, and clear your mind. No phones, no distractions. We have too much swirling in our heads.
Again, as with all random internet advice, you are under no obligation to do anything you don't feel is safe for you. However, some have found this helpful. I also recorded a TikTok about it that is just 1 minute long:
I hope it helps you. Be well!
Sponsor: Simplify code, reduce costs, and build faster without compromising the transactionality, scale and flexibility you need. Fauna - a global serverless database for all your applications. Learn more!
I love emulators. I love that they exist. I love that we have computers that are not only fast enough to translate and emulate instructions in real time for totally different computers that may not even exist any more but also for computers that are shipping today!
Every 6 or 7 years I get a new PC. My most recent one was in 2018 and I'm happily still using it today. However, I have made a few modest and somewhat low-cost (and one high-cost) upgrades. Each of these upgrades means I'll get another 3 to 5 lovely years out of this desktop machine. I'll be using Amazon referral links below, and you are supporting my writing when you use them, thanks!
The #1 thing I'm thankful for is that the ASUS ROG Strix X299-E Gaming II ATX Gaming Motherboard (Intel X299) I purchased three years ago was such a solid choice. It has/had ample memory slots, two (the new one has 3!) m.2 hard drive slots, and it's a large size for future video cards. I'm putting upgrades into this motherboard that didn't exist when I purchased it and it's doing great. If you can, always stretch the budget for a roomy motherboard - you can save up for the upgrades over the coming years like I did.
These are the upgrades I've made over the last year.
New SSD - Low Cost and High Availability
Upgrading your hard drive is a huge benefit and relatively inexpensive upgrade. I originally had a Western Digital Black 512GB SSD using an m.2 interface. This was my first "hard drive that doesn't look like a hard drive," and I still find m.2 drives to be basically impossibly amazing.
I noticed that my Drive Health, per CrystalDiskInfo was in the low 60%s and the ATTO Benchmark was getting weak on the writes.
I upgraded to a Samsung 970 EVO Plus SSD m.2 NVMe for just $165. This drive is double my original's space and nearly 3-4x the perf in some places. Plus, the Samsung Drive Migration software just worked. I literally added this drive to my second m.2 slot, ran the migration, shut down, moved the drive to the first m.2 and removed the old drive, and rebooted. I didn't get a single complaint from Windows.
This is NOT a sponsored post. This product and technique just worked and I'm thrilled. You may also be able to get a similar result from Clonezilla and another drive, but I was very much impressed with Samsung and this upgrade.
Here's the before and after benchmark between the 2018 WDC m.2 SSD and the new Samsung EVO Plus SSD.
Before:
After:
Comparing this drive to my D: and E: spinning rust (regular) hard drives is the difference between shooting a bullet and throwing it. This SSD is 10x faster than a regular drive.
Memory - Medium Cost and High Availability
I had 32 gigs of RAM since 2018 but randomly (I know, this is silly) while cleaning my PC noticed I had four memory slots unused. I *did* know this when I bought it but I just flaked or forgot I had the extra space.
While upgrading, I also noticed (with help from Twitter) that I wasn't running the XMP memory profile and running these at 3200Mhz. I was running them at 2133Mhz all this time! Doh. So a nice upgrade and one small switch in the BIOS and I've got 64 gigs PLUS I'm clocking nearly 50% faster.
This has improve performance for me when running Docker and Kubernetes locally along site, Teams, VS, VS Code, Outlook, you know the drill. I usually sit around 35-50 gigs committed when really working with everything open. The extra headroom has been great.
High Cost and Low Availability
And finally, as of the time of this writing, this is one that requires more money and more luck. I used an online bot to look for stock drops of the new NVidia 3080 video cards and got one near Christmas. I've also heard good things about the waiting list at Evga.com.
This card was $699 which was a significant outlay and I went back and forth on it before I decided to go for it. It's proven to be a great upgrade, particularly as an upgrade for video rendering for my YouTube as Adobe Premiere uses it a lot.
I really hope that this card and the more affordable 3060 are more available soon because it's a lovely upgrade.
Take a look at your desktop motherboard and consider your possible upgrades based on cost, availability, and performance and see what you could put together at a reasonable budget! Hope this helps!
Sponsor: Have what it takes to code securely? Select from dozens of complimentary interactive challenges in Veracode Security Labs, test your skills, and earn a badge. Learn more.
Muscle memory is a heck of a thing. When I want to build code I type Ctrl-Shift-B. I can't not. It's built into my hands! Ctrl-Shift-T is test (even though it's non-standard, it's there, in my hands.
I spend a lot of time at the command line, in Windows Terminal, in PowerShell, using PSReadLine. So why not make a few of these intuitive hotkeys work for me there as well?
PSReadLine supports Set-PSReadLineKeyHandler which is basically hotkey bindings to any arbitrary script block.
Here's Shift-Ctrl-B typing dotnet build and pressing enter. Just add these to your $profile, after you've imported PSReadLine via
if ($host.Name -eq 'ConsoleHost')
{
Import-Module PSReadLine
}
Here's Shift-Ctrl-T typing dotnet test and pressing enter.
Set-PSReadLineKeyHandler -Key Ctrl+Shift+t `
-BriefDescription TestCurrentDirectory `
-LongDescription "dotnet Test the current directory" `
-ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("dotnet test")
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}
Here's it in Animated Gif Form! (Using Carnac to see the hotkeys being pressed)
Since I am using Ctrl+Shift+T for testing (that's just me) I did need to manually unbind it from New Tab in my Windows Terminal settings. Just be aware.
{
"command": "unbound",
"keys": "shift+ctrl+T"
},
Sweet. What hotkeys will YOU hook up?
Sponsor: Have what it takes to code securely? Select from dozens of complimentary interactive challenges in Veracode Security Labs, test your skills, and earn a badge. Learn more.
I thought I knew everything about the open source Windows Terminal and then I hit Ctrl+Shift+P like I do in VS Code (muscle memory) and it pops up a lovely Command Palette. You can search for any command and see the current keybinding. Super useful if you haven't yet discovered Window Panes. You can also type new wt.exe command lines and affect the current window.
NOTE: Don't forget, "wt" is an alias for the Windows Terminal, so you can Win+R and type wt and run it!
Since the wt.exe allows for chained commands, I can create a custom command in settings that calls wt.exe with chained commands/actions and bingo, I have a command called Development that opens multiple profiles, splits the screen and sets me up for Windows+Linux development in a single move!
Here I have a new command called Development that calls wt with a new-tab with a named profile, then a split-pane with another named profile.
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.
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.
For example, Command Prompt was here on my machine:
In this case, it's Command Prompt. I also renamed my LNK file to Command Prompt (Terminal) but that's optional.
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.
I even did this with the Visual Studio 2019 Developer Prompt by first making a Profile for it in my Terminal settings:
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!
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)!
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.
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):
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:
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!
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.
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.
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 filethat includes the whole app and .NET, with NO INSTALL.
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!
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!
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.
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.
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.
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.
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?
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.
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.
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.
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.
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!
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!
I found this 5 year old .NET application called FloatingGlucose from Bjørn that connects to a Nightscout open source diabetes server like the one I use and displays your current glucose values in a floating popup on your Windows desktop. It can also connect to the Dexcom Share servers. However, the app has an installer and requires .NET 4.6 to be installed.
How quickly - and successfully - can I convert it to a self-contained .NET 5 app? I don't know, I haven't written that part of this blog post yet. I'm still up here.
NOTE: I'm surprised I can't clone AND get submodules with the GH CLI so I guess I need to git submodule update --init --recursive after the initial use of GH.
And looks like GH is out of date so I'll 'winget install gh' to update it while I'm here.
Entrypoint: C:\github\FloatingGlucose\FloatingGlucose\FloatingGlucose.csproj
Current Project: C:\github\FloatingGlucose\FloatingGlucose\FloatingGlucose.csproj
1. [Skipped] Back up project
2. [Next step] Convert project file to SDK style
3. Clean up NuGet package references
4. Update TFM
5. Update NuGet Packages
6. Add template files
7. Upgrade app config files
a. Convert Application Settings
b. Disable unsupported configuration sections
8. Update source code
a. Apply fix for UA0012: 'UnsafeDeserialize()' does not exist
9. Move to next project
Choose a command:
1. Apply next step (Convert project file to SDK style)
2. Skip next step (Convert project file to SDK style)
3. See more step details
4. Configure logging
5. Exit
> 1
[22:25:49 INF] Applying upgrade step Convert project file to SDK style
[22:25:49 INF] Converting project file format with try-convert, version 0.7.222801
[22:25:52 INF] [try-convert] Conversion complete!
[22:25:52 INF] Project file converted successfully! The project may require additional changes to build successfully against the new .NET target.
[22:25:55 INF] Upgrade step Convert project file to SDK style applied successfully
Please press enter to continue...
So I'm going step by step through the process, answering questions. OK, done. Let's see if it builds.
Looks like it doesn't. It has a custom setup PowerShell script that is trying to call InnoSetup and make an installer. Since I want to make a version that doesn't require an installer, I can remove all that from the PostBuildEvent and PreBuildEvent in the main csproj file.
Now I'm getting a number of compiler errors that aren't related to the conversion, but rather a misunderstanding about how exceptions are to be re-thrown.
When you say "throw err" you're actually losing your call stack and context.
else
{
//rethrow because we don't know how to handle other errors
throw err;
}
Instead, just:
else
{
//rethrow because we don't know how to handle other errors
throw;
}
throw to maintain the current error context. I'm just tidying up at this point.
I see a few warnings like:
C:\github\FloatingGlucose\FloatingGlucose\FormWebbrowser.cs(10,6):
warning SYSLIB0003: 'PermissionSetAttribute' is obsolete:
'Code Access Security is not supported or honored by the runtime.'
and I comment them out as they are vestigial at this point.
I'm down to a final error:
Could not resolve this reference. Could not locate the assembly "System.Windows.Forms.DataVisualization".
Interesting, what's this about? Looks like not all of the Windows Forms DataVisualization project came along for .NET 5? The older code is here https://github.com/dotnet/winforms-datavisualization for .NET Core 3. The readme says "We consider the System.Windows.Forms.DataVisualization deprecated and we only provide it to ease porting to .NET Core 3"
However, Angelo Cresta has a .NET 5 version here https://github.com/AngeloCresta/winforms-datavisualization-net5 so I can try updating to his version. I'll bring it in as a Submodule and then add it as a Project Reference from the main FloatingGlucose app.
I'll also bump the JSON.NET reference from 9 to 13.0.1
NOTE: I'll also put in a dotnet_diagnostic.CA1416.severity = none in an .editorconfig to keep the compiler from warning me that this requires Windows 7 and above.
Boom, this 5 year old app is now a .NET 5 app and builds clean. SHIP IT. Well, test and run it first, eh?
Nice, a clean warning-free build AND it starts up immediately AND looks OK on my 4k monitor likely due to the work that was done to make WinForms apps scale nicely on high dpi systems.
Does it work? Darn right it does.
Fabulous. Now I have a little widget I can have on my screen at all times that shows my current sugars!
And finally, can I make it a single no-install EXE that doesn't even need .NET installed?
Yes, now I have a single EXE I can run of this now .NET 5 WinForms app:
Fab. That was fun. Took about 2 hours. Consider if YOU can update your "legacy" codebase to .NET 5 and reap the benefits! Here is the 'works on my machine' late night release. PR's welcome. Night!
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.
However, REST Book is a Postman-like notebook that uses the Native Notebooks UI experience that's already built into Visual Studio code.
If you already love the concept of Notebooks like I do, you'll love REST Book. It's electric paper! Just like .NET Interactive or Jupyter Notebooks, it mixes Prose and Code in a very clean and very intuitive interface.
Here's me calling into my Nightscout server to see my real-time Blood Glucose:
Pretty cool. It's early days but I think Tanha already has a very interesting combination of a native Notebook experience and a Postman-like experience. Note I've also created a "SECRET" in the form of my API Key, and then I can refer to it in the GET request using $SECRETS.name.
You can also assign variables like:
let foo = GET https://hanselman.com
and then use them in subsequent cells with $.foo.headers.User-Agent, etc.
Just install the Rest Book extesnion in VS Code Insiders, and make a new empty text file with a .restbook extension.
You can do GET and have the URL on multiple lines if you split on a ? or &
GET https://www.google.com
?query="hanselman"
&page=2
User-Agent: rest-book
Content-Type: application/json
And you can POST and each new line will be a Header, until the last lines after a line separator which is the body of the call.
POST https://www.myexampleapi.com
User-Agent: rest-book
Content-Type: application/json
{
name: "Hello",
text: "Hi friends, how are you all?"
}
If you want to get involved, look at the source, file an issue or bug, or just give compliments, do it over on her repository at https://github.com/tanhakabir/rest-book Have fun!
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.