Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / UWP

Programming Windows 10 Desktop: UWP Focus (13 of N)

4.97/5 (6 votes)
14 Dec 2017CPOL11 min read 18.4K   126  
Get Started in UWP (moving away from WinForms) Chapter 13 : Deployment, Sideloading a UWA - How easy/difficult is it, really?

Introduction

This chapter is going to be a bit of a departure from what we've been doing, because there isn't any code this time.  That's because I wanted to examine deployment under the UWP (Universal Windows Platform) paradigm. 

This will be a fast read and allow you to see what UWP deployment is actually like.

How difficult or easy is it to get your apps to other users?  

I was really hoping it would be easy.  You will see the challenges I faced as I attempted to install.

Background

You can read all the chapters that have come before this one:

Programming Windows 10: UWP Focus (1 of N)[^]
Programming Windows 10: UWP Focus (2 of N)[^]
Programming Windows 10: UWP Focus (3 of N)[^]
Programming Windows 10 Desktop: UWP Focus (4 of N)[^]
Programming Windows 10 Desktop: UWP Focus (5 of N)[^]
Programming Windows 10 Desktop: UWP Focus (6 of N)[^]
Programming Windows 10 Desktop: UWP Focus (7 of N)[^]
Programming Windows 10 Desktop: UWP Focus (8 of N)[^]
Programming Windows 10 Desktop: UWP Focus (9 of N)[^]
Programming Windows 10 Desktop: UWP Focus (10 of N)[^]
Programming Windows 10 Desktop: UWP Focus (11 of N)[^]
Programming Windows 10 Desktop: UWP Focus (12 of N)[^]

Image 1Print or Kindle Available at Amazon

You can also read the first 8 chapters of the book as a print or kindle book from amazon:

Programming Windows 10 Via UWP: Learn To Program Universal Windows Apps For the Desktop (Program Win10) [^]

 

 

 

 

Deployment

Now that our app has some useful functionality and it doesn’t crash every time we start it, we may feel like sharing it with others.

In the past, when you created a WinForms app you would just build it into an exe, zip it up and give it to people.  With Windows Vista Microsoft moved to implement a bit more security for users so they might be more aware of when apps were being installed.  Suddenly, apps couldn’t write to the Program Files directory and instead were supposed to install into the Program Files directory and store data in other locations like the ProgramData folder.

Now, with UWP, Microsoft is following the idea of app store deployment by providing the Windows Store and requiring UWP apps to be uploaded by certified developers so users can only install apps from vetted sources.

This follows the model of the industry, first implemented by the Apple App Store and then Google Play.

However, that means is an indie developer wants to put a little app together and give it to her friends it is a bit more difficult now since there are quite a few more hoops to jump through.

Other Ways To Get An App

Apple devices are extremely locked down and if you want to get your app onto a device for testing there is no simple way to deploy it to your friends and family or other testers.  You are basically forced to go through the App Store to get any app onto your device.  If the app is not in the App Store you cannot get it by connecting the device to a computer or anything.  

Sideloading An App

Google makes deployment quite a bit easier.  If you create an app using Android Studio, you can generate an APK for the app and allow users to download it from a web site.  When the target device downloads the APK it will warn the user that it is an installation package but will allow the user to choose to install it if she wishes.

That process is called sideloading.  

Microsoft Allows Sideloading Too

Fortunately, Microsoft allows sideloading also.  That means we should be able to create a installation package and let Windows 10 users know where it is and then they can download it and install it.  Again, this can be nice if you would like to have friends and family try out your app before you do all the work to get it into the Windows Store.

To get this to work, we have to build our installation package.  Visual Studio will help us do that.

Build Our App Installation Packages.

Make sure you have the latest version (DailyJournal_v028 completed in Chapter 12) loaded in Visual Studio and that you have tested the build and made sure it runs properly.

Right-click on the DailyJournal project in Solution Explorer and a menu will appear.

Image 2


Slide down the menu to the [Store] menu item (includes a right-arrow to indicate another menu will pop up).

When you slide over the [Store] menu item the submenu will appear.

Click on the [Create App Packages…] menu item (includes an ellipsis to indicate that a pop up dialog window will appear).

Image 3

 

The radio button will most likely default to [Yes] but we want to select [No] since we just want to create a package that we can sideload.

After you select [No], click the [Next] button to continue through the process.

 

Image 4

 

There’s a lot on this dialog.

First of all, it let’s you know path where it is going to create the installation package.

Next, is the Version information.   We have not done any work in the Package.appxmanifest so it defaults to 1.0.0.0.  However, notice that the [Automatically increment] checkbox is selected by default.  Visual Studio is attempting to help you keep track every time you build a package so that you don’t get your versions mixed up.  

Generate App Bundle

The app bundle contains all of the dependencies the user will need to run your app on her particular system.  Microsoft has designed these app bundles so that if your app runs under multiple languages and multiple Operating System versions (Win8.1, Win10, etc) that the user will only be required to download the appropriate dependencies she needs.

Choosing Architecture and Solution Configuration

Finally, we need to select a type of hardware (architecture) that the app bundle will be installed on.  I currently have a warning that is telling my I cannot target x86 and ARM.  For some reason my Visual Studio continually thinks I’m building for ARM devices.

I finally got the settings correct and all the warnings disappeared.

 

Image 5

Set yours to match so we can continue.

PDB Symbol Files

The last checkbox is [Include full PDB symbol files, if any, to enable crash analytics for the app.]

PDBs are Program DataBase files which are used to track the source code of our solutions so that when an error occurs we can get more detailed information about where it occurred in the app.  You can leave this item checked.

Click the [Create] button to create our package.

On my system when I clicked that [Create] button, that dialog simply disappeared and I couldn’t tell if anything was happening at all.  

My Output window did look like the following, which seemed to indicate that a build was happening:

Image 6

 

Finally, I saw the Output window update to the x64 also.  However, I didn’t see any other lines appear in the Output window.  Possibly because it updated too quickly.  

My point here is that even if it doesn’t seem like something is happening, it probably is.

 

Image 7

 

Finally, after quite some time (depends upon the speed of your system) I saw a dialog box pop up.

 

Image 8


 

I noticed that my Output window was updated with some status info also.

Image 9


 

I clicked the first link on the [Package Creation Completed] dialog box which represents the Output location and File Explorer opened up at the location.

 

Image 10

 

If you look inside that directory one of the things you’ll find is the .appxbundle file.

I assumed that double-clicking the bundle* file would allow me to start the installation process but it isn’t that easy.  Too bad.

*Actually, hang on, because further down this does work for me on another machine.  It seems the one machine didn't have some component that allowed the .appxbundle click install.

Image 11


 

There is another file in that folder named : Add-AppDevPackage.ps1 (PowerShell file).

I right-clicked it and when the context menu appears, I have a menu choice of [Run with PowerShell].


 

Image 12

 

PowerShell pops up a new window and starts running the script and then I see a warning appear.

 


Image 13

I typed a Y and hit <ENTER> and the script continued.

Image 14

I pressed <ENTER> again to continue.

Windows displays the UAC (User Access Control) dialog and I click the [Yes] button.

Image 15

 

PowerShell begins to install the certificate and then warns me again.

 

Image 16

 

I type a Y and press <ENTER> yet again.

 

Image 17

 

So the package installation does fail.  However, that is because it warns me that I already have the app installed and it doesn’t want to overwrite the app.

That’s simply because I ran this on the same machine where I’ve been developing the app.

When I hit <ENTER> this last time, the PowerShell window closed.

Back in Visual Studio I never did close the Package Creation Completed window so I clicked [Close] now to indicate that I’m done. At this time I don’t want to [Launch Windows App Certification Kit] because I’m not deploying to the Windows Store.

Try, Try Again

I decided I wanted to change the version and build the package again and see if it will update the app.  I’m also wondering if the installation will overwrite my current data that I saved in the app.

I double-clicked the Package.appxmanifest file in Solution Explorer and switched to the Packaging section.

I changed the Minor version from 0 to 1 so the version will be 1.1.0 and saved the project.

I made sure I __did not build__ the app, because I figured it might deploy the app and not allow me to install it.  It still may not allow me to install it but I’m giving it a shot.

 

Image 18

After that I headed back over and restarted the packaging process.

That did not work.  It gave me the same error.  It simply knows that this package is installed based upon its package name : 116d1010-a1e4-452a-a1d2-c84aea07af6d

I Am Tenacious

I still don’t want to give up, so I :

  1. brought up the Windows 10 Settings dialog.

  2. Chose the System icon.

  3. Chose Apps & Features.


 

Image 19

 

 

Image 20

 

I found DailyJournal installed in the system.  Hey, nice icon.  :)

I will save off my data first and then uninstall the app so I can test the installation.

Click on the DailyJournal item in the app list and it will display your choices.

 

Image 21

 

Click the [Uninstall] button.

A warning dialog pops up.  Apparently it will remove the app’s data also.

 

Image 22

As the app uninstalls you will see the following (unless your computer is extremely fast).

 

Image 23


Yet Another Attempt

After reading the official Microsoft documentation about sideloading : https://docs.microsoft.com/en-us/windows/uwp/packaging/packaging-uwp-apps

I decided to try again.

I went back to my Win10 machine and double-clicked the appxbundle for my 1.0.0.0 version again.

This time the following dialog box popped up as I had originally hoped:

 

Image 24

The first thing that is interesting is that it shows that Capabilities of [Access your Internet connection] is set.  That’s odd for at least two reasons:

  1. DailyJournal doesn’t have any code to access the Internet in it

  2. I did not add that capability.  However, it may have been set by the original project template.  I will check later.

I left the [ ] [Launch when ready] checkbox selected and clicked the Install button.

The next thing I see is a dialog box that states that the installation failed.

Image 25

You have to scroll down on that weird little text box to see the entire reason.

“Either you need a new certificate installed for this app package, or you need a new app package with trusted certificates. Your system administrator or the app developer can help. A certificate chain processed, but terminated in a root certificate which isn't trusted (0x800B0109)”

I’m just really glad that they gave me the hex value error number.  I love those things. :)

Try the PowerShell Again

I decided to try running the PowerShell script again.   

Image 26

This time it succeeded because I gave it the Admin credentials.  

I hit <ENTER> once again and the PowerShell window closed but the app never started or anything.  

Dude, Where’s My App?

If you go to the Start Menu and open it, you should see the newly installed app.

Image 27

If you don’t see it, you should be able to open the Windows Start menu and then type “daily” and the Windows built-in search should find it for you.

Image 28


 

After that I decided I should try double-clicking the appxbundle file again to see if it would work now that the certificate seems to be installed.  

However, I had to uninstall the application again to try it.

It worked and finally installed from the appxbundle.

 

Image 29


 

Access Your Internet Connection

It looks like the Visual Studio Project template does set the Internet connection capability by default.  

Image 30

 

That's it for this time.

Next time we'll begin to examine individual XAML Controls like TreeView, TextBox, etc.

History

2017-12-14 : first publication of the article

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)