cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Create Desktop Shortcuts in a MSIX Project Using the Package Support Framework

How to Create Desktop Shortcuts in a MSIX Project Using the Package Support Framework

Introduction

This article details the process of generating desktop shortcuts within an MSIX project using the Package Support Framework (PSF).

By default, MSIX packages don't inherently support the installation of a desktop shortcut due to Microsoft's limitation on user-driven preferences. Therefore, actions such as creating a Desktop shortcut or pinning it to the Taskbar or Start Menu are beyond the user's direct control.

However, if you still need to deploy an application shortcut on a user's Desktop through an MSIX package, there is a option available. In this article, we'll explore that option to accomplish this task.

Instructions

Configure the MSIX package to support "Application alias" package. To do that, follow the steps below:

    1. Create a MSIX project.
    2. Add your .exe file under the Files and Folder View > INSTALLDIR.
    3. Go to the Applications View and create a shortcut for the newly added .exe file.
    4. Select the Key Name field on righthand pane.
    5. Rename it to the same name as the shortcut name:key name field.JPG
    6. Go to Declarations.
    7. Right-click then add "New Declaration set."
    8. "Declaration Set 1" will be added.
    9. Right-click on "Declaration Set 1."
    10. Add a "New Custom Declaration."New Custom Declaration.JPG
    11. On the righthand pane, select the Namespace field dropdown menu then select  "Xmlns:uap3= , and xmlns:desktop=" as shown below:

Name space selected.JPG                  12. Select the XML content field then enter the code below and rename the Executable name  and Executable alias name:

 

 

<uap3:Extension
    Category="windows.appExecutionAlias"
    Executable="[ExecutableName]"
    EntryPoint="Windows.FullTrustApplication">
    <uap3:AppExecutionAlias>
        <desktop:ExecutionAlias Alias="[AliasName]" />
    </uap3:AppExecutionAlias>
</uap3:Extension>

 

 

xml context executable path.JPG                 13. Go to the Application View and select the Declaration field and select the newly added Declaration above: Decalartion selection in application.JPG                   14. Save then build the project and install the MSIX package that gets created.
                   15. Make sure the shortcut is created in the Start Menu.
                   16. Press Win+R then type the application name and check that your application launches successfully, which means the alias exe shortcut was created successfully:

                   17. Go to the user's Desktop then right-click and select New --> Shortcut and enter your exe name and click Finish:New shortcut.JPG
                  18. A new shortcut with the name, provided in the dialog above, will be created on the user's Desktop.
                  19. Right-click the Desktop shortcut then select Properties --> and select the shortcut tab.
                  20. Change the target path field and start in field to the LocalAppData path as shown below:target and startin path and shortcut icon.JPG                                                  21. Copy your icon file to folder path under LocalAppData --> package --> Roaming where our application folder is created with the product name and random ID. For example: C:\Users\Administrator\AppData\Local\Packages\MSIXTestShortcut_d14rjvjqp047y\LocalCache\Roaming:

iocn file copied.JPG                  22. Click the change icon button and change the icon from above copied to the LocalAppData Roaming folder path:

ico changed for shorcut.JPG                                               23. Click OK then Finish and close all dialogs. Now, we have a new Desktop shortcut with an icon created.
                     24. Now, we have to automate this process using PowerShell in the Package Support Framework (PSF).
                     25. Copy the icon file and the newly created shortcut in to our test data folder as shown below: copied ico and lnk file.JPG                           
                       26. Add the value copied from above to the project .ism file > INSTALLDIR: files added.JPG                                 
                                27. Download the attached ZIP files then extract them and paste them into the same test data folder (the .json file, createshortcut.ps1 file, and the StartingScriptWrapper.ps1 file).
                             28. Edit the .json file and change the executable name to your exe name and edit the id and change the shortcut to the "Key Name" field value.
                             29. Save then close the jason file.jason edit.JPG

                         30. Now, open our MSIX package's project .ism file then go to the Application View --> Select the shortcut created and select Fixup Type under "Package Support Framework."
                         31. Click on the + icon then select Custom Fix Up:

custom fix up PSF.JPG

                        32. Set Architecture to x86 and the .json path to the test data folder where the .json file was copied to:

jason path.JPG

                           33. Now edit the createshortcut.ps1 file then change the path and name of the file, per the shortcut and .ico file that was created. Save and close the powershell script file:

create shortcut powershellscript edit.JPG

                       34. Go to the Files and Folders View and add both StartingScriptWrapper.ps1 and createshortcut.ps1 in to our project's INSTALLDIRscript files added.JPG

                  35. Select the Root Node (the Destination computer node) then add the JSON file config.json and save the project .ism file:

jason file added.JPG

               36. Save and Build the project.
               37. Install the newly built MSIX package.
               38. Observe a desktop shortcut is created when launching your application, which runs the PowerShell script to create the Desktop shortcut.

NOTE:

  1. Make sure all machines have the remote execution policy enabled to run a PowerShell script without any issues.
  2. The workaround installs a conventional .lnk desktop shortcut rather than a contemporary application entry.
  3. The script is triggered only after the application is initiated, allowing the Desktop shortcut to be copied.
  4. The MSIX uninstallation process does not include the removal of Desktop shortcuts, necessitating a separate action to address this, which is currently not supported using script as well.
  5. Inadvertently deleting the Desktop shortcut won't be resolved by repairing the MSIX package, as it won't automatically restore the shortcut. Reinstallation after uninstallation of the MSIX package is necessary to recover the Desktop shortcut.

More Information

Click here for Microsoft PSF help link.

Click here for Microsoft documentation on how to create a desktop shortcut.

No ratings
Version history
Last update:
‎Mar 14, 2024 03:40 AM
Updated by:
Contributors