Microsoft Visual Studio gets .NET Core debugging – on WSL2

'Higher fidelity local debugging experience' than debugging on Windows and deploying to Linux

Hands On Microsoft has pushed out an extension for Visual Studio 2019 that lets developers run and debug a .NET Core application on Windows Subsystem for Linux 2 (WSL 2).

The pre-release extension addresses what is now a common pattern for .NET Core developers: you use Windows to create and edit a web application or microservice, but deploy to Linux, gaining more deployment options and lower licensing costs. It may also perform better.

A test by developer Roberto Prevato in late 2017 found the same application performing significantly better on Linux.

More evidence that .NET Core runs well on Linux comes from Adtech company Criteo, which reports that "we migrated one of our biggest server consuming app out of windows. Running on .Net Core on Linux/Mesos/Marathon. 5300 mesos instances, 159k vCore, 320TB RAM evalutating 532M campaigns for 4M users every second. Less than 10ms on average."

Pic for .NET Linux piece

Click to enlarge

The new option gives what Microsoft calls a “higher fidelity local debugging experience,” compared to doing all your debugging on the Windows side before deploying to Linux and hoping it works the same.

The prerequisites are Windows 10 and WSL 2 with Ubuntu or Debian installed, and Visual Studio 2019, with the free Community edition good enough. The extension was previewed by Microsoft in its May virtual Build event, but is only now available to download.

We gave it a try. The extension seems well done. Once installed, a “WSL 2” option appears in the drop-down choices for starting a debug session, and when selected, prompts for installation of .NET Core 3.1 on the “remote” Linux operating system. It then automatically deploys the required files.

The .NET Core SDK gets installed on the Linux side, but the application source code remains in the Windows file system, accessed via the /mnt/[driveletter] path.

Our .NET Core web application worked first time, with little to show that it was running on WSL 2 other than messages in the Debug window about loading files from /mnt/c/Users/[username] and so on.

Breakpoints are hit, you can step through code, and everything works. We were not so lucky with a .NET Core React.js application, which complained about permission errors (node_modules/.bin/rimraf: node: Permission denied); but this is a pre-release.

How useful is it?

Microsoft offers various ways to debug .NET Core applications on Linux. One is to use Visual Studio Code running on Linux, which works pretty well and is arguably a better environment than Visual Studio for JavaScript debugging. Another is to run Visual Studio on Windows and deploy to a Linux Docker container; this has worked with debugging support for some time.

Another option is to use Visual Studio Code remoting, which lets you run the editor and debug on the Windows side while compiling and running on the Linux side. This is similar to how the new Visual Studio extension works, but takes more effort to set up. Unlike the new extension, though, VS Code remote development works with remote Linux servers as well as with WSL 2.

Since the idea is to verify that a .NET Core application runs the same on Linux as on Windows, it would be helpful if the Visual Studio test runner would execute tests in the WSL 2 environment - but this is not supported.

Some issues then, but another small piece in Microsoft's improving support for Linux development on Windows. ®

Similar topics

Other stories you might like

  • Prisons transcribe private phone calls with inmates using speech-to-text AI

    Plus: A drug designed by machine learning algorithms to treat liver disease reaches human clinical trials and more

    In brief Prisons around the US are installing AI speech-to-text models to automatically transcribe conversations with inmates during their phone calls.

    A series of contracts and emails from eight different states revealed how Verus, an AI application developed by LEO Technologies and based on a speech-to-text system offered by Amazon, was used to eavesdrop on prisoners’ phone calls.

    In a sales pitch, LEO’s CEO James Sexton told officials working for a jail in Cook County, Illinois, that one of its customers in Calhoun County, Alabama, uses the software to protect prisons from getting sued, according to an investigation by the Thomson Reuters Foundation.

    Continue reading
  • Battlefield 2042: Please don't be the death knell of the franchise, please don't be the death knell of the franchise

    Another terrible launch, but DICE is already working on improvements

    The RPG Greetings, traveller, and welcome back to The Register Plays Games, our monthly gaming column. Since the last edition on New World, we hit level cap and the "endgame". Around this time, item duping exploits became rife and every attempt Amazon Games made to fix it just broke something else. The post-level 60 "watermark" system for gear drops is also infuriating and tedious, but not something we were able to address in the column. So bear these things in mind if you were ever tempted. On that note, it's time to look at another newly released shit show – Battlefield 2042.

    I wanted to love Battlefield 2042, I really did. After the bum note of the first-person shooter (FPS) franchise's return to Second World War theatres with Battlefield V (2018), I stupidly assumed the next entry from EA-owned Swedish developer DICE would be a return to form. I was wrong.

    The multiplayer military FPS market is dominated by two forces: Activision's Call of Duty (COD) series and EA's Battlefield. Fans of each franchise are loyal to the point of zealotry with little crossover between player bases. Here's where I stand: COD jumped the shark with Modern Warfare 2 in 2009. It's flip-flopped from WW2 to present-day combat and back again, tried sci-fi, and even the Battle Royale trend with the free-to-play Call of Duty: Warzone (2020), which has been thoroughly ruined by hackers and developer inaction.

    Continue reading
  • American diplomats' iPhones reportedly compromised by NSO Group intrusion software

    Reuters claims nine State Department employees outside the US had their devices hacked

    The Apple iPhones of at least nine US State Department officials were compromised by an unidentified entity using NSO Group's Pegasus spyware, according to a report published Friday by Reuters.

    NSO Group in an email to The Register said it has blocked an unnamed customers' access to its system upon receiving an inquiry about the incident but has yet to confirm whether its software was involved.

    "Once the inquiry was received, and before any investigation under our compliance policy, we have decided to immediately terminate relevant customers’ access to the system, due to the severity of the allegations," an NSO spokesperson told The Register in an email. "To this point, we haven’t received any information nor the phone numbers, nor any indication that NSO’s tools were used in this case."

    Continue reading

Biting the hand that feeds IT © 1998–2021