Packaging UWP Application with more than 25GB Data


uwp-application-with-different

Problem Statement

We were working on a Digital Signage application, where we have used Universal Windows Platform (UWP). The application heavily depends on the data files, i.e., the quality images and videos and their effective navigation is key in this application. The Total size of data files is very huge (more than 25 GB). We can not package this app as there is a restriction on the Package Size that it can be 25 GB maximum per bundle.

In this article, I will be sharing how we shipped this application which had huge data.

Prerequisites

  • Familiarity with creating Universal Windows Platform (UWP) applications
  • Familiarity with Application Design

Load data through external device

We solved this particular problem by separating application package from its data. By doing this, we reduced application package size to be as small as possible. Data is shipped separately via an external device, for example, USB. We added required logic to make the application smart by detecting external drive when inserted and copied the same data into the local machine.

Steps:

  • Keep the Application Package as light as possible and separate this from data files
  • Data files need to be shipped separately in the form of  USB
  • As and when the Application is installed and started for the first time, it checks for the data folder. As it is running for the first time, it will not find data. Depending on the configuration, the installer Prompts the user to insert a drive consisting of the data files.

Code:

Please find the code logic for detecting external storage and copying data into AppData folder as mentioned below. At the start of the Application, we’ll verify to check whether data is available locally or not. If not, we try reading it from external storage (App.xaml.cs).

 /// <summary>
 /// Invoked when the application is launched normally by the end user. 
 /// Other entry points
 /// will be used such as when the application is launched to 
 /// open a specific file.
 /// </summary>
 /// <param name="e">Details about the launch request and process.</param>
 protected override async void OnLaunched(LaunchActivatedEventArgs e)
 {
      #region System-Generated-Code
      #if DEBUG
      if (System.Diagnostics.Debugger.IsAttached)
      {
        this.DebugSettings.EnableFrameRateCounter = true;
      }
      #endif
      Frame rootFrame = Window.Current.Content as Frame;
      // Do not repeat app initialization when the 
      // Window already has content,
      // just ensure that the window is active
      if (rootFrame == null)
      {
        // Create a Frame to act as the navigation context and navigate
        // to the first page
        rootFrame = new Frame();

        rootFrame.NavigationFailed += OnNavigationFailed;
 
       if(e.PreviousExecutionState == ApplicationExecutionState.Terminated)
       {
         //TODO: Load state from previously suspended application
       }

       // Place the frame in the current Window
        Window.Current.Content = rootFrame;
     }
     #endregion
     if (e.PrelaunchActivated == false)
     {
        if (rootFrame.Content == null)
        {
          // When the navigation stack isn't restored navigate 
          // to the first page,
          // configuring the new page by passing required information 
          // as a navigation parameter
          bool IsDataLoadedFromUSB = false;
          if (!await new StorageManager().IsDataAvailable())
          {
            await new USBManager().SetUpAppDataFromExternalStorrage();
            IsDataLoadedFromUSB = true;
          }
          rootFrame.Navigate(typeof(MainPage), IsDataLoadedFromUSB);
        }
        // Ensure the current window is active
        Window.Current.Activate();
     }
 }

 

Summary

This article explained how to package Universal Windows Platform (UWP) Application whose data size is > 25GB. I hope this article guides you in taking an informed decision.

At WalkingTree, we are excited about UWP’s ability to enable developers to build app which runs on windows-based devices of different sizes. We continue to take advantage of this and love to help you as well.

You can find the complete source code at this repository.

References

  • For information on App Package Requirements – Refer to this link.
Tagged with: ,
Posted in UWP
2 comments on “Packaging UWP Application with more than 25GB Data
  1. venkataramanam says:

    Glad to know that it helped you. Keep visiting us for more interesting information.

  2. CS-Cart says:

    Great, thank you for the excellent article, it is very useful information for online businesses.

Leave a comment

We Have Moved Our Blog!

We have moved our blog to our company site. Check out https://walkingtree.tech/index.php/blog for all latest blogs.

Sencha Select Partner Sencha Training Partner
Xamarin Authorized Partner
Recent Publication