NET MAUI Comes to VS Code
Written by Mike James   
Wednesday, 12 July 2023

At last, Microsoft seems to be serious about making .NET and C# something you would want to use with VS Code. But there is still a long way to go.

I have to admit right now that I'm a long term WPF and Visual Studio programmer and I generally use VS Code for every language apart from C#. The reason is that a C# project is so heavily structured that I'm put off by the idea of having to deal with, let alone generate, all those boilerplate files. Generally using Visual Studio you can simply ask for a project to be created and then sit back and concentrate on just the few files that define your UI, main program and additional classes. Until recently VS Code just allowed me to edit C# files and a few other project configuration files, but provided little help in creating or maintaining them. As a result the full Visual Studio was so much better - a true IDE as opposed to a code editor.

csdevkit4

The big change was the announcement of the C# Dev Kit, which I looked at last month. This is a big step in the right direction, but only if you want to create ASP apps - and lots of devs do. But when it comes to desktop apps C#Dev Kit is a non-starter.

Now we have the .NET MAUI extension. This pairs with the C# Dev Kit to extend the range of projects you can create to include .NET MAUI apps.

In case you have missed it .NET MAUI is an open source development on Xamarin Forms, which used to be a way to create .NET apps for the Mac and other platforms. Note that .NET MAUI is not Windows Forms and it is not WPF, both of which still exist and are used. Like WPF, however, MAUI is procedural and, like WPF, you can use XAML to generate a UI, but there is no drag-and-drop editor to help you prototype things. However you can use MAUI to generate apps that run under Windows, Android, iOS and Mac OS - the same code runs on all of these targets. In this sense it is an alternative to Flutter, Cordova and similar.

The new extension is relatively easy to install as it sets up C# Dev Kit and warns you if you don't have .NET or .NET MAUI, but it doesn't help you much with getting them installed. Currently the following debug targets are supported:

  • On Windows, you can debug to your local Windows machine, Android emulators, and Android devices
  • On macOS, you can debug locally on your Mac, on iOS simulators or devices, and Android emulators or devices
  • On Linux, you can debug to Android emulators and devices

Linux looks a little under served in this list, but then MAUI doesn't support developing Linux apps - which is a shame. The project can either be a Mobile/Desktop app or a Blazor/Mobile/Desktop app.

Once you have everything installed you can either open an existing project, which is unlikely in my opinion, or start a new one via the command palette. This generates a complete project with a single page and a "Hello World" UI:

mauihelloworld

This ??is quick and easy and editing C# is as always not a problem and there is intellisense help when editing the XAML. However, it isn't as user-friendly as Visual Studio and you will end up wondering how to do something that should be easy. Overall, Visual Studio still wins hands down - especially if desktop Windows apps are your target.

There is one final twist that I commented on when the C# Dev Kit was announced - you have to sign in to use it and if you are a big company you have to pay for a licence and you can't use the extension on any virtual environment that isn't Azure. The extensions are still open source, but the licence brings C# development using VS Code inline with using Visual Studio.

Microsoft needs to carry on building VS Code as its coding environment for Azure and this probably means that slowly but surely it has to reach parity with Visual Studio - but that seems a long way off as yet.

  • Mike James is the author of Deep C#: Dive Into Modern C#,  in which he provides a “deep dive” into various topics that are important or central to the language. By exploring the motivation behind these key concepts, which is so often ignored in the documentation, the intention is to be thought-provoking and to give developers confidence to exploit C#’s wide range of features.

More Information

Announcing the .NET MAUI extension for Visual Studio Code

Related Articles

C# Dev Kit For VS Code Brings Sign In To FOSS

VSCode Can Do More Than You Imagine

Visual Studio Code Adds Language Detection

VS Code Improves Docker Support

Open Source Visual Studio Code Without Trackers Launched

Run VSCode in the Browser

VS Code Extensions As Malware

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


A Tee Is Not Just For Xmas - Top Tees
20/12/2024

Programmer gifts - easy idea, difficult implementation.  Here's our pick of tee-shirts for giving, buying or just wearing at any time of the year.



Azure Container Apps Dynamic Sessions Generally Available
02/12/2024

Dynamic Session support has been added to Azure Container Apps. Azure Container Apps is a serverless platform for running containerized applications, and dynamic sessions is designed to provide fast a [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

<ASIN:1871962714>

<ASIN:B09FTLPTP9>

Last Updated ( Wednesday, 12 July 2023 )