This post is part of the 2022 C# Advent series. Big thanks to Matthew Groves for putting these on every year. Be sure to check out the other author posts to learn some awesome C# content!
If you're running Windows on Arm devices like I am, 2022 has been the holy grail for news surrounding Windows 11 on Arm and development tools. The Visual Studio 2022 17.3 previews (only, and not the GA release) included a sneak peak of what a fully Arm-native Visual Studio would look like. Upon hearing the news that Arm64 support went GA with the release of 17.4 during .NET Conf, I immediately rushed to upgrade and was met with a barren wasteland in the realm of VS extensions I could install.
What did I do after being faced with this? Figure out how to add Arm64 support to some of the extensions that I use. This blog post will walk through the steps needed to make this happen for .NET based extensions.
- Visual Studio 2022 17.4 or above for Windows with the Visual Studio extension development workload installed
- A Visual Studio extension project
- Preferably a device running Windows 11 on Arm. How else are you going to test? You can always ask me to test and I'll help out 😎.
The steps for adding Arm64 support to Visual Studio 2022 extensions are easily listed in Leslie Richardson's blog post from September. I recommend reading through that blog post first, because I'm going to walkthrough a lot of what is described on there, but from the way I figured it out.
First step, make sure you have Visual Studio 2022 17.4 and above installed. This is important as earlier versions will throw warnings and possibly errors.
Ensure you have the
Visual Studio extension development workload installed
This workload will also automatically install the
.NET Framework 4.7.2 targeting pack. Since I'm on my Windows Dev Kit 2023, I also have the .NET Framework 4.8 and 4.8.1 development tools installed, but this isn't necessarily required if building from an x64 machine.
Add/Upgrade NuGet Packages
Update all NuGet packages to their latest versions. The most important ones to update are the
Microsoft.VisualStudio.Sdk packages. Any version that is at least 17.4 is the good to go.
Target .NET Framework 4.7.2 or Newer
From troubleshooting and inspecting the default .NET Framework version chosen when creating a new Visual Studio Extension project, you will need your main project to target .NET Framework 4.7.2 at minimum in order for the solution to properly compile for arm64 support. This guidance also applies to building from x64 Visual Studio.
Account For Native Dependencies
If your extension relies on native dependencies that are targeting the x86 or x64 platforms, make sure that an arm64 version of that dependency exists. Failure to do so will result in the extension or that part of the extension crashing. The exception to this rule is when the native dependency isn't involved with the execution of the extension, but for compiling the extension. For example, if you're primarily building from an x64 machine and use an MSBuild task that loads a native dlls like NerdBank.GitVersioning , you can continue building. The downside is being locked to x64 for build and deploy.
Add Arm64 As Installation Target in Extension Manifest
The same modifications made to the
source.extension.vsixmanifest to target amd64 are the same ones you'll need to make for arm64. The easiest way to add the arm64 target is to copy/paste the existing
<InstallationTarget> tag and set the value of the inner
<ProductArchitecture> tag to
If you prefer to make these changes within the Visual Studio GUI, open the
source.extension.vsixmanifest file in the designer. Click on the
Install Targets, click the
New button, then fill out the necessary information.
Product Identifier: Microsoft.VisualStudio.Community
Version Range: [17.0, 18.0)
Product Architecture: arm64
If this architecture target isn't added, the VSIX will fail to install on Visual Studio 2022 for Arm.
The extensions targeting
AnyCPU for the build platform will be complete. A simple build will generate a Visual Studio extension package targeting both x64 and arm64.
Debugging the extension in Visual Studio will run a new instance of Visual Studio 2022 in an experimental mode. The extension will be installed in this instance, allowing you to step through and test it before deploying the Visual Studio extension package. Debugging the extension will work the same way as it does on an x64 Visual Studio instance when targeting AnyCPU. If you've created separate x64 and arm64 solution targets, debug using the proper platform.
Be sure that you've completed the previous steps to add an arm64 installation target, as you can debug the extension in the experimental instance without adding that target.
Deploy the extension as you would normally. How can you tell whether the extension is properly targeting arm64?
Check the marketplace listing. The
Works with section will show
Visual Studio 2022 (amd64), 2022 (Arm64)
If you have an Arm64 Visual Studio instance handy, you will see the extension appear in the Visual Studio Extension Marketplace within the IDE.
- MIDL Extension Pull Request
- Tweakster 2022 Extension Pull Request
- Roslynator 2022 Extension Pull Request
- SpecFlow Extension Pull Request
- Visual Studio Extension Documentation
Adding Arm64 support to existing and new Visual Studio 2022 extensions is a fairly simple task. I've been able to knock out contributions to update extensions within a day or so. Why did I do it? Because I wanted my development environment to mirror the same extensions that I use on an x64 machine. I urge ALL Visual Studio extension developers to consider updating extensions to include targeting Arm64. For most, the effort isn't significant and the Windows on Arm developer community is growing.
I'm voluntelling y'all to get out there and contribute if you can!