Publishing a C++ Win32 MFC Application to the Microsoft Store
So, you have decided to publish a Win32 App to the Windows Store for fun or profit! Like mine, your App probably draws on large libraries in C++, and you want to develop the whole App in C++. I choose to develop in C++, and I still build user interfaces using MFC. It’s old-school, but it still works! I hope this article provides you with some useful tips for getting your App onto the Microsoft Windows Store.
For the purposes of full disclosure, when I wrote this article, I was running Windows 10 Pro (version: 21H1, build: 19043.1706) and Microsoft Visual Studio Community 2022 (version: 17.2.1).
Here is what you will need to get started.
- Microsoft Windows 10 or 11 and Microsoft Visual Studio.
You will need Windows 10 or 11 installed and fully updated, and I recommend using the latest version of Visual Studio. For clarity, I am still using Windows 10 and have not done any testing on Windows 11. Make sure that you are signing into Visual Studio using the same Microsoft account that you use to set up the partner centre.
- Microsoft account.
Make sure you have a Microsoft account, and you know your username and password.
- Developer Settings.
Open Settings in Windows 10 and search for “Developer Settings”, Make sure “Developer Mode” is enabled.
- Register your business.
You ought to register your business and acquire the appropriate registration documentation. For example, in Australia, this will be your Australian Business Number (ABN).
- Build a website for your business.
- Build a YouTube channel for your business.
To document your software and to widen your communication channels with your users, I strongly recommend you get into the business of video production. OBS Studio is your best starting point for recording instructional videos. For help, I recommend checking out Kevin Stratverts’ instructional videos on YouTube. https://www.youtube.com/c/KevinStratvert
- Email account.
You will need an email account, and you may wish to redirect emails from your website to your company or personal email account.
- Credit card and banking details.
If you plan to monetise your Apps, you will need a credit card for making payments to Microsoft and banking details for receiving payments from them. You ought to seriously consider creating bank accounts in your company name.
- Build an app!
Build and test your application. Make sure it has a high-quality icon, try to make it high DPI aware, and know what all your DLL and resource file dependencies are.
Microsoft Partner Centre
Go to the Microsoft app publishing website and begin to do your research.
Once you have a feel for what you need to do, go to the Microsoft Partner centre.
- Register as an app developer in the Microsoft Partner Centre.
To publish an app, you will need to become a Microsoft Partner. There is a one-time fee to join which is about $20 USD for an individual. They will take your payment immediately, but it may take days for your account to be verified, so it is best to get this going early.
Most likely you will want to choose the Individual account type. You will need to enter your publisher name (probably your business name), your email address, company website URL, company or personal phone number, company or personal postal address and company registration (like your ABN).
You will need to sign into your Microsoft account, add a billing method, and pay by credit card. You may wish to review the App Developer Agreement. Note that Microsoft take a 15% cut of any sale, or a 30% cut if the app is classed as a game, and that these rates are occasionally reviewed. You can now log into the partner centre dashboard.
Microsoft have updated this dashboard and now have a “Workspaces” view, which is the default. I think it is an improvement, but if you want you can turn this view off, and it reverts to the old view.
You can change the Azure AD directory to access different services. You ought to have one linked to your email address and one linked to your company name. To create a new app, access the AD linked to your email address.
You will need to provide banking details to Microsoft so that you can be paid for your sales. For developers outside of the USA, there are forms to be filled in declaring your exemption from US taxes, if your country has a taxation agreement with the US. The procedure to do this is long and complicated, and they will ask you a whole bunch of questions that you will neither understand nor know the answers to. If you have a partner who works in the tax office (like I do!), it is a good idea to have her/him on hand to provide moral support!
- Create a new app.
Open the Apps and Games workspace and, in the Overview page, hit the “+ New Product” button and select a new App or Game. You will need to reserve your app name and make sure it is available, then begin your submission. Your submission contains all the information that will appear on the Microsoft Store as well as the application packages which contain the code, dependencies, and resources.
Work through the six submission information categories. You can find more detailed help elsewhere for these options. There is plenty of text and data in the submission and you may want to keep it all in a document so that you can improve it as you proceed and as the app develops.
You will need a support email address and a product website URL. You will also need plenty of high-resolution images or artwork to visually support your app. Prepare a description of the app elsewhere as you will probably want to finesse this key advertisement.
The “Short description” is the first thing customers will see on the store listing. It needs to be very short – tweet short! It will be truncated, and customers will not be able to read it if it exceeds the allowable length. I found it needs to be less than about 150 characters (25 words).
I like to include links to my website and to YouTube videos and playlists. However, the store does not present these as clickable links. Also, they can only be copied out of the store listing if they appear in the “Description” field. I put all links into the Description field exclusively.
If you are developing for Xbox, then you will need plenty of additional store art. I created a Store Logo Poster Art image but found that this does not appear on the Store listing in Windows 10 for a Windows application.
- Build the package for your app.
To get your app into the store you need to build an installation package that you will upload. The mechanism to do this has changed over the years. Firstly, there was a product called the “Desktop Bridge App Converter” and you can still find this on the Windows Store. This was replaced by the “MSIX Packaging Tool” which is also on the store. But the way to do it now is to use Visual Studio.
Add a new Visual Studio MSIX project to your existing Win32 app solution in Visual Studio. If you do not see this project option, you may not have it installed. Basically, you just add your existing Win32 app project as a dependency to the new MSIX project. The websites listed below can give some guidance. Follow the cookbook, add a reference to your app project, set up the build configurations as required, and you should then be able to build the MSIX project.
You will need to specify the Windows target version and the minimum version. To support automatic updates, you need to target Windows 10 version 1803 (Build 17134) as a minimum version. The wizard chooses 1809 as a minimum. For help choosing versions, you can visit this website Choose a UWP version – UWP applications | Microsoft Docs.
You will need to edit the MSIX project package manifest. Go through these settings carefully and make all the appropriate declarations. You may need to come back here later to fiddle with the certification.
If your app depends on DLLs or any other resource files, then you will need to add these to the MSIX project. I add a folder called “Dependencies” to the project to house all the DLLs and a folder called Resources to house all resource files needed by the App (you will already have a folder for Images). Use Visual Studio to add all your dependencies into these folders.
- Build an MSIX installation and test it.
Before you build an MSIX for uploading to the Store, you will want to test the MSIX locally. Firstly, build the MSIX project. Then choose the “Publish” option and select “Create app packages”. To build and run it on your local machine, you can choose the “Sideloading” option. Make sure you select the correct build configuration. You will need a certificate and you can create a local one here.
Once you have successfully worked through the publishing wizard, you will have an MSIX package – most likely a bundle. You can double-click on this to install it locally.
All MSIX apps get installed into a hidden directory under “Program Files/WindowsApps”. You cannot browse this directory and all files under it are locked down by the OS. You can see the file structure by looking under the “obj” folder in your MSIX project output. You will see the app executable file under a separate folder and your resource files may be in the folder above it or in a parallel folder. It is likely that your EXE file and your DLLs will not be in the same folder.
This folder structure may cause you grief. In a normal Windows app installation, we expect the DLLs to be in the same folder as the EXE and we also expect the current working directory to be the directory housing the EXE. In an MSIX app, the CWD is the System32 folder, and the DLLs are somewhere else altogether. You may need to finesse your code and review all calls to SetCurrentDirectory and SetDLLDirectory and LoadLibrary to make sure that resources are being accessed.
If you need to debug your application, I have found the best way to do it is to install the app, then use the Visual Studio Debug>Other debug targets>Debug installed app package… option. Select your app and it will execute and you will be able to set breakpoints as usual.
- Associate your MSIX project with your app on the Store
In Visual Studio you can associate your MSIX project with the app name that you have reserved in the Microsoft Store. Thereafter, you can publish to this app name automatically. Right-click on the project and look under the Publish item for this setting.
- Upload your MSIX package.
Use the publish wizard again, but this time direct it to the Windows store rather than side loading.
One common problem at this stage is the size of your PNG file image assets. Microsoft sets a maximum size and if you exceed this it will not build the package. I use TinyPNG to shrink the image files where needed.
Now you can go back to your submission and upload the package. If you have already uploaded a package you will have to delete it before uploading a new package. This process seems to cause grief – I recommend deleting the old packages, saving, then editing the package again, and uploading the new package.
The package will then be verified and sometimes you run afoul of certification at this stage. You need the Store to build a new certification certificate for your package. One solution, where you associate the project with the store app, is described in this blog post.
Another solution is to –
- Open the Package.appxmanifest file editor.
- Go to the “Packaging” tab.
- Copy the Publisher DN (the number after CN=).
- Click the button “Choose Certificate” and select the item “Create test certificate…”.
- Copy the publisher DN from step 3 to the first editable text field.
- Submit your app for publication.
This will take a little while, possibly up to several working days. Every now and then, check back in and see how it has progressed. I had one submission that took a full week!
- Update your app with new features and bug fixes
After you see your app for the first time in the Store, it is likely that you will want to update all the text and images, and basically start again. Before long you are also likely to want to update the code with some last-minute bug fixes. To update all of this, you need to prepare a new submission. The new submission will start as a complete copy of your last submission, and you change the items you want to update.
When you update your code, make sure you advance the package version when you prepare it. I find I need to remove the current package from the “Packages” section of the submission, save it, then go back in and add my new (updated) package. Even so, I have had difficulty uploading a new package and receive messages like “Your submission contains a package that has the exact same package full name as another package…”. I found deleting everything in the “AppPackage” directory in the Visual Studio MSIX project, then rebuilding the package helped.
Make sure you update the store details to include descriptions of new features and changes.
Your customers will receive updates in the background and most likely they will not notice that an app has been updated. To update apps manually, go to the store and select the “Library” option and update from there.
- Send your app to your friends for free testing!
For a product that is not free, you can order promotional codes so that your friends and colleagues can download a free copy. Carefully consider who is a friend. They are taking money out of your pocket!
Do this from the Partner centre via the “Attract” option. Microsoft supplies some good documentation for this process. Order your codes and then download them. Inside the file is the code redeeming URL that you send out as a freebee. Demand a five-star review as payment!
Good luck with your publishing journey and I hope you make some money!