Dave Leverton Dave Leverton - 3 months ago 19
PowerShell Question

UWP's 'Add-DevAppPackage' Powershell script checks for a developer licence. This is an issue for Sideloading?

I'm developing a LOB (Line-of-Business) UWP project, we're hoping to distribute the app as a

.appxbundle
file, alongside a
.cer
and a Powershell script. This is what is generated in the package for you when you generate a bundle from Visual Studio by selecting
Project->Store->Create App Packages...


The problem I have is that the Powershell script,
Add-DevAppPackage.ps1
, has a check for a developer licence in it. Specifically it calls the powershell cmdlet
Get-WindowsDeveloperLicense
. If this doesn't return anything it sets a variable which eventually calls
Show-WindowsDeveloperLicenseRegistration
which shows a popup forcing the user to put their Windows 10 device into 'Developer Mode'. If the user doesn't do this, then the Script fails and the user can't install the app.

If we remove this check for a Developer Licence, the script acts as I'd expect and Installs the App, alongside the certificate, with no issues when the Windows 10 machine is either set to 'Sideload Apps' or 'Developer Mode'. The problem now arises when the users device is in the mode of 'Don't use developer features'. The script crashes.

Is there a way of finding out if the current device is in 'At Least' Sideload apps mode, and if it isn't, show a dialog to prompt the user to enable it?

Currently users have to enable Developer Mode to be able to sideload an app, which I'd prefer they didn't have to do. I'd fully expect users to only have to enable 'Sideload apps'

Answer

Is there a way of finding out if the current device is in 'At Least' Sideload apps mode, and if it isn't, show a dialog to prompt the user to enable it?

AFAIK, there is no way to detect whether the Sideload apps mode is enabled for now. And we have no access to show a dialog to prompt the user to enable the sideload apps.

The problem now arises when the users device is in the mode of 'Don't use developer features'. The script crashes.

This is because when install apps in Sideload apps mode, you need to install the app with its trusted certificate. All UWP apps must be signed with a certificate.

Currently users have to enable Developer Mode to be able to sideload an app, which I'd prefer they didn't have to do. I'd fully expect users to only have to enable 'Sideload apps'.

Before create the package of your project, you can open the manifest file and in the Packaging lable:

enter image description here

Here you can choose which certificate to use to sign your app. If you don't want to modify this, it's OK, cause when you packaging your app, a certificate file will automatically generated, and you said you are hoping to distribute the app as a .appxbundle file, alongside a .cer and a Powershell script. In Sideload apps mode, the Powershell script file is not needed. You can just copy the .appxbundle file and a .cer file, and

  1. Enable the Sideload apps mode.

  2. Click the .cer file to trust this certification.

  3. Click the .appxbundle file to install your app.

When the Sideload apps mode is enabled, please don't use .ps1 file to install the app.

Comments