Technical Case Study for converting Glimpses WPF application to UWP


Anees Ahammed, Founder and Developer of Glimpses, teamed up with us for a multi-day Hackfest; during which we worked on converting his application glimpses to UWP app and publish it to the Windows Store.

Core Team:

  • Anees Ahammed (@AneesAhammed) – Founder and Senior Software Engineer, Glimpses
  • Rami Sarieddine (@RamieSays) – Senior Technical Evangelist, Microsoft
  • Hatim Nagarwala (@hatimnagarwala) Application Developer, Microsoft

Glimpses

Glimpses was founded and developed by Anees Ahammed back in 2016. He wanted to create a simple and fluid application to write down your thoughts and capture your memories and have these synced and backed up in the cloud. He built glimpses as a desktop application, specifically for Windows, to be used as a personal journal where you can track your daily activities, capture your thoughts, record your travels, and people you meet.

The application works on Windows 7, 8 and 10 with a smart set of features including:

  • Timeline view to rediscover your memories with beautiful images
  • Integrated calendar view to easily view and create an entry on a specific date
  • Tags to organize your journal entries with weighted multiple color tags
  • Distraction free writing to helps you stay focused
  • Favorites section to easily find and view your most preferred entries
  • Supports Markdown-Preview
  • Export to PDF
  • Spell check and Retro/Typewrite mode
  • Publish to create a shareable link

Problem statement

Glimpses was built for Windows with C# and WPF. It is made available for download from the official website as a standard "exe" application. The WPF application works great as a desktop application but does not offer the best modern app experience for Windows 10 users. Nevertheless, Anees would love to get his application on the Windows Store and incorporate some Universal Windows Platform (UWP) features to it but cannot afford the time or resources at the moment to develop a new UWP app from scratch.

Using the bridge, you can gradually migrate your older code to UWP while still retaining the ability to run and publish your app on Windows Desktop.he but they would not want to rewrite all the code to create a new Universal Windows Platform (UWP) app to leverage Windows Store capabilities.

Anees sees that the UWP platform offers some great features that could improve the user experience like Cortana Integration, Live Tiles and Share target. Moreover, with a growing 400 million users on Windows 10, distributing the application through the Windows Store will expand the reach to millions of Windows 10 users

In addition, converting Glimpses Windows desktop application will harness the following benefits:

  • Streamlined deployment experience ensuring that users can confidently install an app and update it. If a user chooses to uninstall the app, it's removed completely with no trace left behind. This reduces time authoring setup experiences and keeping users up-to-date.
  • Automatic updates and licensing with the Windows Store's built-in licensing and automatic update facilities. Automatic update is a highly reliable and efficient mechanism because only the changed parts of files are downloaded.

With all of the above potential benefits in mind, we teamed up to work on converting and publishing the application.

Solution, steps, and delivery

The conversion process included the following steps:

  • Prepare to convert

    Before running the app against the converter, we needed to go through the checklist of "things to consider" when converting with the Desktop to UWP Bridge. We might not have to do much to get the app ready for the conversion process, but this allows us to determine if any of the items in that checklist applies to the application so we can address it before the conversion. One major case we identified in the preparation phase was the automatic updating, the application uses squirrel framework for auto-update so the execution point would normally be "%localappdata%\glimpses\Update.exe". The Windows Store actually handles licensing and automatic updating so we can remove the features that relate to those tasks from the codebase. In this case, the auto-update from squirrel framework is not necessary so we replaced the path of the executable to link to the starting point  of the application "<file path>\glimpses.exe" as the following screenshot shows:

  • Convert using the Desktop App Converter

    There are several options to convert the application including:

    Desktop App Converter (DAC): A tool that automatically converts and signs the app for you.

    • Manual conversion with the MakeAppx.exe tool
    • Visual Studio which is similar to the manual option described above except Visual Studio does a few things for you such as generating an app package and the visual assets for your app
      • Third-party installers:
      • Advanced Installer by Caphyon
      • InstallShield by Flexera
      • WiX by FireGiant
      • RAD Studio by Embarcadero
      • InstallAware

    We opted to use the Desktop App Converter (DAC) as it is convenient and automatic. The converter runs the desktop installer in an isolated Windows environment by using a clean base image provided as part of the converter download. It captures any registry and file system I/O made by the desktop installer and packages it as part of the output. The converter needs a couple of steps to be setup:

    • Downloading and installing the Desktop App Converter
    • Run the Desktop App Converter as an administrator
    • Download the Desktop App Converter base image (*.wim), we used Creator's Update since the version number of the base image in the name of the file should match the version number of the Windows build we had running
    • In the console window that started with the Desktop App Converter, we ran the command: Set-ExecutionPolicy bypass.
    • Set up the converter by running this command: DesktopAppConverter.exe -Setup -BaseImage .\BaseImage-1XXXX.wim -Verbose.
    • Restart the machine

    Next, we started with converting the application which is as simple as running the DesktopAppConverter.exe command in the console window that opens when you start the Desktop App Converter. The command requires the following parameters to specify the package name, publisher and version number of the app.

      DesktopAppConverter.exe
      -Installer <String>
      -Destination <String>
      -PackageName <String>
      -Publisher <String>
      -Version <Version>
    

    Our command looked like the following:

      DesktopAppConverter.exe -Installer C:\Installer\Release\ -AppExecutable glimpses.exe -Destination C:\Installer\Output 
      -PackageName "glimpse" -Publisher "CN=E4D612D4-CF50-44B1-BFE7-456E75098099" -Version 1.1.10.0 -MakeAppx -Sign
    

Since the above command points the installer to the executable file so this will auto-update the file path in the Appmanifest.xml.

During the conversion, we faced some technical issues but we managed to resolve those and get the app working. At first, we actually tried the default command for conversion:

DesktopAppConverter.exe -Installer c:\Installer\glimpses-setup.exe -Destination ..\Appx0105 -PackageName "glimpses" -Publisher "CN=Anees" -Version 0.1.2.26  -MakeAppx -Sign -verbose

The above command failed as the application installer was packaged with Squirrel which is a set of tools and a library, to completely manage both installation and updating Desktop Windows applications. The problem was that Squirrel by default runs an update.exe which doesn’t allow the application to load. So we tried to point to the app executable as follows:

DesktopAppConverter.exe -Installer c:\Installer\glimpses-setup.exe -Destination ..\Appx0105 -PackageName "glimpses" -Publisher "CN=Anees" -Version 0.1.2.26 -AppExecutable "glimpses.exe" -MakeAppx -Sign -verbose

The above command converted the app and it worked but when we ran the UWP it would hang after we log in with either Dropbox or with a Gmail account. Trying to resolve the issue, we removed a few local settings from the code but that didn't fix it.

After further investigation in the original code base, we learned that the application writes Log files on the drive including pictures, SQLite database and a backup of the documents in an encrypted format. So we tried to move this logic from the AppData to MyDocuments but the issue persisted.

Next, we tried removing the log files which were generated in the actual installation folder but still, the problem was not solved.

Finally, we noticed that the SDK "Awesomium" being used in the application was creating a debug.log file in the installation folder as soon as the user logs in and that was causing the application to hang and crashing on the Main Page load.

The application code depended heavily on the SDK so we couldn't remove that and the only other alternative was to disable the logging which the SDK doesn’t allow. As a workaround, we opted to create a file as debug.log in the installation folder and with read-only permission which solved our problem. With this resolution, the SDK tries to write but is unsuccessful which is not a major issue to the function of the application and hence the app runs fine and doesn't crash.

  • Create Package and Publish

    After we ran the converted app and verified that it is working fine, we needed to sign the app for distribution so it can be published to the store.

    • We converted the final version of the exe using the following command: DesktopAppConverter.exe -Installer C:\Installer\Release\ -AppExecutable glimpses.exe -Destination C:\Installer\Output -PackageName "glimpse" -Publisher "CN=MyPublisher" -Version 0.0.0.1
    • Edit and save the app manifest (appxmanifest.xml) file to add the Store App Identity details by updating the DisplayName, PublisherDisplayName, and Description values.
    • Next, we created new assets and added those to the assets folder with the path to the icons in the appxmanifest.xml and changed the version to 1.1.10.0
    • Last step was to create the App package that we will upload to the store, from the Visual Studio developer command window, we executed the following command in the output folder which was created during the conversion:makeappx.exe pack /d PackageFiles /p “glimpse.appx” /l

Below are two screenshots of the UWP on the Start Screen and the UWP running:

Conclusion

Enclosing, the application is now available on the Windows Store for download and we have the Desktop App Converter to thank for that. Glimpses was able to achieve the following with this conversion:

  • Increase their reach and drive their users to the Windows Store using the Microsoft badge on their website
  • Streamline and simplify the deployment and update experience
  • Prepare the application to incorporate new features from the UWP platform in order to provide the Windows users with great experience

Additional resources

Comments (0)

Skip to main content