Adding URI activation to AppxManifest.xml

Copper Contributor

Hello,

We have automated the EXE to MSIX packaging process. However, we need the created MSIX package's AppxManifest.xml to contain a URI scheme for URI activation(https://docs.microsoft.com/en-us/windows/uwp/launch-resume/handle-uri-activation). This is currently possible through the MsixPackagingTool.exe GUI version(package editor).

1) Is it possible to specify this URI through the MSIX template?

2) If not, is there a way to automate the addition of these entries using any command line tools after creating the MSIX package?

Thank you!

7 Replies

Hi @uvinabeysinghe,

 

To clarify your issue, is the URI handler you want added to the msix package a URI handler that the exe already registers?

 

MSIX packaging tool already scans the registry for protocol registrations during conversion. If we are missing an expected registration, I'd like to identify what we missed during conversion.

 

If you need to add this protocol handler after conversion:

RE 1: No, the Command line interface template does not support specifying a protocol for addition.

RE 2: You could write a script that uses makeappx (App packager (MakeAppx.exe) - Win32 apps | Microsoft Docs) to unpack the msix, use your favorite text manipulator to edit the manifest file, then repack and resign the msix with makeappx/signtool.

 

If you could describe in more detail the specific business need/scenario you are trying to address, that would help us prioritize and evaluate whether this would benefit from specific feature additions to the tooling. Are there other fields you find necessary to manually add in general post conversion?

 

Thanks!
James

Hi @James Pike ,

We have created “myapp_setup.exe” which we converted to “myapp.msix”.  When we install “myapp_setup.exe”, we create below registry keys for supporting the uri protocol “myapp-name://“ 

 

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\myapp-name]
@="URL:myapp-name"
"URL Protocol"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\myapp-name\shell]
@="open"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\myapp-name\shell\open]
@=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\myapp-name\shell\open\command]
@="\"C:\\Users\\username\\Applications\\MyApp\\MyAppName.exe\""

 

 

But when we install “myapp.msix” only some of the above registry keys get created. Also, note that the absolute path to the exe file will be different in the case of MSIX installation as it gets installed to C:\\Program Files\\WindowsApps folder. 

 

For testing purpose, we tried to manually create these registry keys after installing the MSIX package. But, the URI protocol does not work and we see permission denied errors in the process monitor logs. 

 

What is the recommended method for supporting URI protocols in MSIX packages? Should we work on getting the registry keys to work , which we believe requires fixes in the MSIX packaging tool.

 

Or, should we be focusing on automating the addition of the URI protocol XML entries in the App Manifest. For this case, it will be helpful if you could create an enhancement request for supporting this in the MSIX packaging tool. If this is what is recommended, we can consider using the MakeAppx tool for now. 

 

We would like to automate this soon. Currently our team is manually creating MSIX files. This takes a lot of time because we have to create several MSIX files for our product releases. 

Thank you!

@uvinabeysinghe 

 

I believe the supported way to use URI handlers in MSIX packages is to register them in the AppxManifest.xml. As you saw, creating registry keys pointing to the executable inside the installed MSIX will fail due to lack of permissions to access the WindowsApps folder.

 

As James said, the MSIX packaging tool already scans the registry for URI protocol registrations, and from the snippet you provided the tool should be able to handle yours during conversion. For this you would not add something to the template but change the installer you provide to the packaging tool.

 

You can create an installer script (e.g. a Powershell script) that runs myapp_setup.exe and then adds the registry keys you need. Then give this installer to the tool. The tool will see both the changes created by myapp_setup.exe and the registry keys, and it will create the appropriate manifest entries for you.

 

You can also test this manually without a script, but you will want to create the script to automate it. For this you can do the conversion from the tool GUI, and add the registry keys while in the Installation page of the wizard.

 

Let me know if that helps.

@Chacon  As suggested above, we can consider creating a powershell script for creating the registry keys, but we assume the functionality would still not work in the MSIX package due to the lack of permissions.

 

Based on this, we think that automating the addition of app manifest entries is the best way forward. We'll try to use the makeappx tool (App packager (MakeAppx.exe) - Win32 apps | Microsoft Docs) to achieve this. It will be helpful if the MSIX converter is enhanced in the future to support this workflow.

Thank you!

@uvinabeysinghe 

You are right in that using the registry keys to register the URL handler pointing to the installed MSIX package will not work. What I am suggesting instead is to create the registry keys so that the MSIX Packaging Tool generates the manifest entries you need. I didn't mean it as an alternative to adding the manifest entries, but as a way to let the tool do add them for you.

 

This only works during conversion and not after creating the package. If the packaging tool sees that the installer creates a registration for "C:\Users\username\Applications\MyApp\MyAppName.exe" to handle protocol "myapp-name", then it will create the manifest entries needed to do the same in the package.

Hi @Chacon ,

 

We tried running the powershell script to install the registry keys during the conversion and the url protocol entries get added to the app manifest correctly.

 

We are trying to understand why the MSIX package converter detects the registry keys created from the powershell script and does not detect the same registry keys created by our app installers during installation.

 

We also recently noticed that the MSIX package converter adds the url protocol app manifest key for one of our app “setup.exe"s but not the rest of "setup.exe"s without the powershell script adding the registry keys. We are wondering why it works for some app installers and not for the others.

Thanks!

@uvinabeysinghe 

 

Glad to hear it worked.

 

To investigate why it detects the URL handler for only some apps, you can check if the registry keys were captured by the packaging tool by manually inspecting the virtual registry of the package using the Package Editor. Whether the keys are in the virtual registry or not, has no effect on the URL handler being registered but it tells you for certain whether the problem is that the packaging tool is not seeing the registry keys being created, or that it does see them but does not handle them correctly.

 

If the tool is not seeing the keys being created, it could be for example that they are being created after the tool stops monitoring system changes.

 

If the MSIX packaging tool is not interpreting the registry keys correctly to create the manifest entry, you can inspect the conversion logs which may tell you why the URL protocol handler was not added. You can also share the conversion logs here or through Feedback Hub for us to take a look. If you do, please review your logs for any private information you would prefer not to share with us.