Azure Virtual Desktop (AVD) – Packaging the SQL Server Management Studio (SSMS) to MSIX

This post has been republished via RSS; it originally appeared at: Microsoft Tech Community - Latest Blogs - .

In this post I will demonstrate how to package the Win32 SQL Server Management Studio (SSMS) to MSIX, that will be consumed later on Azure Virtual Desktop through MSIX App Attach.

 

MSIX is a Windows app package format that provides a modern packaging experience to all Windows apps. The MSIX package format preserves the functionality of existing app packages and/or install files in addition to enabling new, modern packaging and deployment features to Win32, WPF, and Windows Forms apps.

 

MSIX reduces the complexity of managing applications and golden images in AVDs. Through AVD application groups, applications can be instantly available without the need to create new Golden images. When FSLogix FSLogix Profile Containers and MSIX App Attach are used together, the operating system remains clean and the data, profile, and applications are completely separate.

 

The MSIX Packaging Tool enables you to repackage your existing desktop applications to the MSIX format. It offers both an interactive UI and a command line for conversions and gives you the ability to convert an application without having the source code. We want to enable IT Pros to convert their existing assets to MSIX, to give them a better way to do packaging and app management.

 

msixpackagingtool.png

 

In case you can't install the MSIX Packaging Tool from Microsoft Store, you can download the offline version here.

 

Another great option is to use the free Hyper-V image Windows 10 MSIX packaging environment that provides a Windows 10 image with the MSIX Packaging Tool already installed.

 

hyper-v.png

 

 

Packaging the SSMS to MSIX

 

Open the MSIX Packaging Tool and click Application package to create a new package for the application:

 

 

mpt_01.png

 

 

The MSIX Packaging Tool will monitor the changes that will be made to the operating system. For this, it is possible to use a virtual machine to install the application or the physical machine itself.

 

The best scenario is to use a virtual machine so that the same process can be repeated if necessary. It is important that the machine, used to install the application, does not contain the previously installed applications and their components.

 

Choose the desired scenario and click the Next button. While running the tool on a virtual machine, I selected the first option:

 

mpt_02.png

 

n this step, the tool will check if the MSIX Packaging Tool driver is already installed and will also disable Windows Update to decrease the number of changes to the operating system. The driver is already installed in the version provided by Hyper-V.

 

mpt_03.png

 

 

If you got an error to install the tool driver, please refer to this post that describes how to manually download and install the driver up to version 1809. Starting with version 1903, you need to download the Windows 10 Features on Demand ISO and copy the Msix-PackagingTool-Driver-Package.cab.

After verifying that the driver is installed, click the Next button.

 

Provide the installer of your application. It is important to note that the installer is not required, as the tool monitors all changes made to the operating system. I will provide the SSMS-Setup-ENU.exe installer.

 

Select the certificate that will be used to sign the package. The certificate is only required in case you want to install the app outside of the Microsoft Store (sideloading). For more information about how to create a self-signed certificate, please check this doc.

 

mpt_04.png

 

The next step is to fill in information such as the package name, the description that will be displayed to the user during installation, the vendor's name (must be the same as the certificate), and the version number. Fill in the requested information and click the Next button:

 

 

mpt_05.png

 

The following screen will appear and from then on, the tool will monitor the changes made to the operating system.

 

mpt_06.png

 

The installation will start automatically because we provided the SSMS installer.

 

mpt_07.png

 

 

In this step, I am just changing the destination path to reduce the path size. This is totally optional.

 

mpt_08.png

 

 

Click on Install and wait for the installation.

 

mpt_09.png

 

After completing the setup:

 

mpt_10.png

 

At the end of the installation, click the Next button. On the next screen, you need to define which apps will be visible in the start menu. I am keeping the suggested ones:

 

mpt_11.png

 

Click the Next button to continue.

 

The next screen asks for confirmation if the environment monitoring is done. Click the Yes, move on to continue:

 

 

mpt_12.png

 

On the next screen, just click on the Next button, since the SSMS application doesn't implements any service:

 

mpt_13.png

 

 

Now it is necessary to inform where the package will be generated, as well as it is possible to edit the package before saving it. Click the Package Editor button to review the package structure.

 

If we just finish the packaging process here, we will get the following error after trying to run the Microsoft SQL Server Management Studio 18 packaged version:

 

Cannot find one or more components. Please reinstall the application

Using PROCMON, I just figured out that the issue happens because the SSMS tries to write an entry in the virtual registry of the package:

 

Process: C:\Program Files\WindowsApps\SSMS_1.0.0.0_x64__kz5d2ck10dqg4\VFS\ProgramFilesX86\SSMS\Common7\IDE\Ssms.exe
Operation: RegCreateKey
Result: ACCESS DENIED
Path: \REGISTRY\WC\Silo1fa4901f-dcbc-d730-8d7c-9e234216dc86user_sid\SOFTWARE\Microsoft\SQL Server Management Studio\

 

It can be fixed using the new flexible virtualization feature that provides a way for your app to declare that some set of its files and Registry entries should be visible to other apps; and that those should persist on app uninstall. All other files and Registry entries are not visible to other apps; and are removed on uninstall.

 

Starting from Windows 10, version 21H1, the system retains the existing behavior of the unvirtualizedResources restricted capability, and the RegistryWriteVirtualization and FilesystemWriteVirtualization properties. In addition, the system adds the ability for your app to declare specific folders and/or Registry keys that you want to be unvirtualized.

 

Click on the Open File button to edit the package manifest (AppxManifest.xml file):

 

 

mpt_14.png

 

Add the following line in the XML namespace session:

 

xmlns:virtualization="http://schemas.microsoft.com/appx/manifest/virtualization/windows10"

 

 

mpt_15.png

 

 

The next step is to declare the following code inside the Properties session:

 

<virtualization:RegistryWriteVirtualization>
     <virtualization:ExcludedKeys>
       <virtualization:ExcludedKey>HKEY_CURRENT_USER\Software\Microsoft\SQL Server Management Studio\</virtualization:ExcludedKey>
     </virtualization:ExcludedKeys>
   </virtualization:RegistryWriteVirtualization>

 

mpt_16.png

 

 

Finally, the last change is to add the following required capability:

 

<rescap:Capability Name="unvirtualizedResources" />

 

mpt_17.png

 

 

Save and close the file.

 

Click on the Virtual registry menu item, browse the REGISTRY\USER[{CurrentUserSID}]\SOFTWARE\Microsoft\, and delete the SQL Server Management Studio key:

 

 

mpt_20.png

 

 

Follows the expected result:

 

 

mpt_21.png

 

 

When finished, click the Create button and inform where the file should be generated:

 

 

mpt_18.png

 

 

The following message will be displayed informing you that the package has been generated.

 

mpt_19.png

 

 

 

Please notice that now the package can be deployed only using PowerShell or via App Attach.

 

addpackage01.png

 

Follows the package details:

 

getpackagedetails.png

 

 

Follows the app running as MSIX on Windows 11:

 

packagedapp.png

 

 

I hope you like it.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.