Forum Discussion
uvinabeysinghe
Sep 07, 2020Copper Contributor
Adding URI activation to AppxManifest.xml
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!
- James Pike
Microsoft
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- uvinabeysingheCopper Contributor
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!- Chacon
Microsoft
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.