How to create the store package (appxbundle) in Winui by using Command prompt or powershell #9121
Replies: 4 comments 4 replies
-
The first thing to point out is that you are generally going to be working towards making a .msixbundle file. The store does accept submissions with the .msix, .msixbundle and .msixupload extensions. The .msix files have been copied to a directory under D:\Packaging.
The makeappx command creates the .msixbundle file. You must then sign it with your code signing certificate if you wish to be able to side load the package. I use signtool specifying an already installed certificate for this. But any method of signing the bundle will work. This .msixbundle should be uploadable to the store as is, but creating the upload file, which includes the debug symbols, is recommended. From here, to create the .msixupload file requires some means of creating .zip files. You should also include the debug symbols for your project, including all architectures that was added to the bundle. These should be in a file with a .appxsym extension. If Visual Studio already created these, use those. If not, you will want to find all of your .pdb files. Remember, these are specific to your executable and library files, so you will need to separate them out. This also means that the .appxsym file would need to be recreated if you rebuild the project. As a side note, since these remaining files are all renamed .zip files, you can just use explorer to create a .zip file and copy everything needed into each file. You would then need to change the extension. Each platform directory contains the .pdb files for that platform. As a side note, only .pdb files that are generated from your build should be included here. With this layout, I can use some command line tool to generate the .zip file. Powershell also has the Compress-Archive cmdlet. If I use 7-zip to generate the .zip files:
Finally, from the layout shown in screenshots above, you can finally create the .msixupload file from the bundle and symbols.
|
Beta Was this translation helpful? Give feedback.
-
download this target file and import into your csproj file and now you can create msixbundle with visual studio wizard |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer, but I need a command to create a package via the command prompt for the WinUI project. So, anyone can help by sharing a command to create a package. If it is a video or code snippet, it is better for us. |
Beta Was this translation helpful? Give feedback.
-
Now for a little step by step guide on how to take the output of the build process and package it on the command line. I save the log from the Publish option. I also heavily referenced the intermediate build output for both the application and the packaging process. So, to make a disclaimer immediately, this general process should work for any application type. It is up to you to figure out the layout of the package, what files you want in the resources.pri file and how the package itself is supposed to be set up. Because each application is different, I can only provide general instructions. I will be working towards bundling up a WinUI 3 project for 3 platforms. It is an executable with a WinRT component. The build output itself will be coming from a C++ WinUI 3 project. The only configuration change I made is that I added So, step 1 is to build your project and make sure that it is in a ready to run configuration. How you do this is outside of the scope of this guide, but if you are working with a C# project then you really should make the C# runtime self contained. You do not have to make the Windows App SDK self contained though. Step 2. Set up the packaging directory. I had it configured so that it was per platform. If you only want to make a single platform .msix package, then you don't have to do this. But when you are working towards uploading to the store, then this kind of layout is useful. Step 3. Copy the required build output to the packaging directory. This is for x64, the same files are copied for x86 and ARM64 from the relevant build output directories. The presence of Microsoft.WindowsAppRuntime.Bootstrap.dll is only for testing purposes. This will not be part of the package. Importantly, I have not copied any of the .xbf files here. You can see that the embed.resfiles is not 0 in size. This means that the files named in embedded.resfiles will be embedded into the .pri file. If you ever want to know the contents of a .pri file, makepri has a dump command. So, to look at the contents of the TestBundle.pri file above, I can use the command:
This will place the contents of the .pri file into a readable xml file. The output of the above is:
As you can see, App.xbf, MainWindow.xbf and TestPage.xbf are all marked clearly as embedded. TestPage.xbf comes from TestComponent, so the other important points that you can see from this are that the resources for TestComponent must also be in the main resources.pri (or executable's .pri file for unpackaged applications), and they must also be under a subtree with a name that matches the component. If the files are not marked as embedded, then you must copy them to the correct package locations too. More on this later. Step 4. Generate resources.pri. The package resources.pri file must also contain the resources for the package, not just the application. So any images that you use in the AppxManifest.xml file must be in indexed in resources.pri. To start this off, I configure the packaging artefact directory as follows: The package images are in the Image directory. The base resources don't need to be per platform, I keep doing it this way because that is how Visual Studio does it and without a script to generate these files on the fly, it is easier to keep things per platform. I create 5 files and one directory. These files are priconfig.xml, filtered.layout.resfiles, pri.resfiles, resources.resfiles and embed.resfiles. Again, these names are not required, I just used them due to Visual Studio doing the same. The contents of priconfig.xml is:
Since I am using the output of a Visual Studio build with the fully generated .pri files, I don't need the resources.resfiles and embed.resfiles sections. However, this is how Visual Studio generates it and I think it is a nice template. The big things to note is that the Language is set to en-GB here, this is the default language that I set. This would change depending on the default language you want in your application package. The Scale is the default DPI scaling that is chosen by Visual Studio, you can again change this. You can configure this as you want, this file uses the same format as the UWP resource management system. So you can use that documentation as reference. Both resources.resfiles and embed.resfiles are empty here. For the remaining files, pri.resfiles contains the absolute path to the .pri files generated by Visual Studio.
You can see that the path contains a platform identifier, but these .pri files should be the same regardless of platform. So if you are feeling adventurous, then maybe you can slim this down a little. Finally, filtered.layout.resfiles contains the relative path to the package image files. The directory that it is using as the base directory is given in the makepri command line. The contents is:
The contents matches the contents of the Images directory in the package artefacts directory. With these files in place it is time to run makepri. The command that I used is:
The -ProjectRoot option tells makepri what directory to use as the base directory for any relative lookups. So when it looks in the priconfig.xml and finds Step 5. Generate the package file. First of all, I am creating the package using a mapping file. This isn't the only way of doing this. I prefer using the mapping file since it gives more flexibility. The mapping file contains the types of resources available as well as the files in the package. The files are a pair of paths, the absolute path name of the existing file and the relative path to the file in the package. This file will be named main.map.txt and will be placed in the platform specific package artefact directory.
I then create the AppxManifest.xml file. This is also placed in the platform specific package artefact directory.
It should go without saying that this file is very customised to my application. In general, you need to fill out the identity, phone identity, properties and applications elements to match your package. I cannot give you information on how to fill this out. This manifest also has an Extensions section due to the WinRT component, this provides activation information for the package, but again, this is something that is needed due to my package layout. This also uses the pre Windows 10 2004/20H1 method of stating that the application is a packaged windows desktop application that runs at medium IL. Again, this will change depending on your application. You really need to reference the manifest schema to figure out how to fill in your AppxManifest.xml file. With the file map and the AppxManifest.xml file completed, you will then run makeappx:
Finally, sign the package with your certificate, if necessary.
Again, the certificate is your code signing certificate. I used a certificate that is in my user's certificate store, so I was able to reference it by the hash alone here. This step is needed if you want to side load the application. You can use the same instructions to generate the packages for the other platforms. Obviously substituting platform paths and any other processor specific values. Once you have all packages created then you can bundle them up. But wait, these do not have the split resources. Because of how long this post is, I will cover the remaining topics in a separate post. As a major note, while this is packaging up a project that is built for WinUI 3, these manual packaging steps are completely technology agnostic. If you are targetting WinUI 2 in a UWP application or using WinUI in a Xaml Islands desktop application, these steps will also work. You just need to modify the resources.pri, file map and AppxManifest.xml accordingly. |
Beta Was this translation helpful? Give feedback.
-
How to create the store package (appxbundle) for WinUI project by using Command prompt or PowerShell command.
Without using the visual studio for creating the package.
Beta Was this translation helpful? Give feedback.
All reactions