In the previous two blogs I discussed using the Web Portal running on a Windows 10 Phone to remotely or in-phone install and Universal Windows Platform app. In this blog I discuss options for install UWP app packages on Windows 10 IoT devices. This is a work in progress as I have not had success some of these methodologies.

  • Now includes Web Device Portal UWP app running locally on IOT-Core Device.
  • AppInstall issues have now been resolved.

 

If you can assist with any of the issues highlighted here, please post a comment here or on GitHub; or email me. Thx

GitHub: IoTBrowser Sample

Some Previous Blogs

IoTSysInfo Blogs:

Previous two blogs:

Sideloading

 

IoTSysInfo

In an earlier blog I discussed a my IoTSysInfo Project on GitHub that implements some of the Device Manager Web Portal functionality (and more).  IoTSysInfo Project on GitHub. The app actually directly uses some of the same function calls that  the web portal calls in JavaScript, Aspect of the Appx Install are included such as getting the files and certificates but I was not able to implement the actual appx installation. I recently had a communication requesting the implementation on AppInstall functionality in the project:

For customers an IoT is not a phone nor a PC. It's just a device. Probably with a display if needed. Some buttons and a lot of connectors/sensors. Most probably he's expecting a web interface to see data and configurations. And the IoT is doing only one thing. If the customer needs to do something else he will get another IoT with a different functionality. What the customer is not expecting is another web interface on port 8080 with the ability to update the App. And selecting the App, the certificate and several dependencies is not easy too. Our dream web interface will have an update function where a Zip can be loaded and the update is done.If this is not possible I believe IoT with Windows 10 is dead.

 

I have been working on methods to implement appx installation as part of the app. My preference is to make use of of a suitable UWP API. Alternatively ot call out to some other on board service for UWP. As stated, this is a work in progress and I have not yet got a working UWP appx installation working. Please provide feedback if you can assist, thanks.

About IotSysInfo

A Windows 10 IoT device has a web portal in which you can view various aspects of the running device. You can also set some aspects. The readable status items are accessed via the portal gain this access through REST calls from JavaScript. This app uses the same APIs and accesses them through REST. As the responses are in JSON format, the app recursively parses the response to generate the information to be displayed.

imageClick to expnd

 

Lets look at options for implementing appx installation on a Windows 10 IoT-Core device

 

In what follows, the status of the methodology is indicated thus:

  • Thumbs up Works
  • Thumbs down Doesn’t work so far
  • Computer ToDo (Haven’t tried it yet)

 

Device Manager Web Portal Thumbs up

This method is the similar to that discussed in the previous blog for the phone. You run a web browser and target the devices IP Address but you use the port 8080. The port can be changed in the registry. The service can be turned off and on. the AppX tab on Device Manager is the same as for the phone except that unlike the phone, there is an option to include the certificate file from the built Appx folder.

 

The source for the Device Portal is available on a Windows 10 IoT-Core device in: 

\\<IpAddress of Device>\c$\Windows\WebManagement\www

clip_image002

clip_image003

 

clip_image002[4]

This includes the JavaScript so it might be possible to build an app around this.Computer

 

IoT Browser Sample App Thumbs up

The Web Portal can be run remotely on any suitable browser. As there is no web browser app in the IoT image it cannot be run on the device, without one being installed.

There is a sample UWP Web Browser app that uses WebView XAML control on GitHub: IoTBrowser Sample

This IS now implemented, does work and is on GiHub. Smile

https://github.com/djaus2/IoTWebDevicePortal

 

PowerShell Thumbs down

When a package is created, there is a PowerShell script in the package folder. Whilst this works seamlessly when a desktop package PS script is run, the issue is can it be used in a PowerShell that is logged into an IoT-Core device? The script is not package specific.

image

I tried copying an ARM package folder across to a RPI3 running IoT-Core Build 14342.

I connected to the device from PowerShell on my desktop, logging in as Administrator on the device.

I then changed director to the Appx folder and issued the command Add-AppDevPackage.ps1

I got an error to do with code signing. I guess this would work if I properly signed the package. The documentation suggests that you can run in developer mode but I couldn’t get that to work.

 

AppInstall Sample Thumbs up (Updated 18 June 2016)

There is an AppInstall sample on GitHub: AppInstall on GitHub

This is no UWP app to build. There are two batch files that you modify for the package and place with the package files (.appx, .cer, and depdendancy .appx’s) in \Windows\AppInstall. You then place a provide command file, oemcommnd.cmd in \Windows\Sys32 on the target. You then reboot the device and the app install runs on booting.

I found it did not work. It did some writeline style debugging with the batch and command files and found it fell over on the actual installation. It might be that it needs to run in some elevated mode.

Footnote: In examining this I tried to use the on device command shell but it kept giving me an error. It said I had to enable the command processor in registry which I did but that didn’t solve the problem, even after a reboot.  Nb The batch and command files did run at boot.

The AppInstall tool at AppInstall on GitHub is for the Threshold version of IOT-Core, 10532 not the Insider Preview versions. One of the key tools used by this package has changed, The Insider preview vesrion will be address in the next blog.

The AppInstall on GitHub version does work with the Threshold version of IoT-Core. Smile.

 

The simplest way to use the AppInstall tool is to download it from GitHub and configure the tool folder on the desktop and copy via file share to the IoT-Core device (or via FTP). Then run a PowerShell or SSH shell on the device and change to the AppInstall folder and run ./AppInstall

image

The AppInstall toolkit

 

AppInstall.bat and DeployAppx.bat have to modified for the particular application package as does the dependencies.

oemcustom.cmd  is also included in the tool. This will autorun the installation at start up but is not required for a manual installation.

 

winappdeploycmd Thumbs down

With the Windows 10 SDK installed on a desktop you can use winappdeploycmd command to install appx packages on a Windows 10 phone that has sideloading enabled. A typical command is:

winappdeploycmd install -file  .\myapp_1.1.16.0_ARM.appx       -ip <ipaddress of phone> –pin <pairing pin>

This assumes that you have a path the the SDK and you are running the command prompt in the relevant package folder.

Notre that this tool actually runs on the desktop but performs a remote installation on the phone but requires a pin from the phone for security.

The pin is determined from the phone’s Developer settings.  It would be sweet to be able to use this tool for remote app installation on a Windows 10 IoT-Core device there isn’t a way to get a pin from the device. Even if security is resolvable, the question then is would that OS support this command.

 

APIs Thumbs down

Ideally there would be a Windows 10 UWP API that could be programmatically called to implement the appx installation.

 

There is a Windows 8  Add Appx Package Sample at code.msdn.microsoft.com. The main code from that is:

Uri packageUri = new Uri(inputPackageUri);                            Windows.Management.Deployment.PackageManager packageManager = new Windows.Management.Deployment.PackageManager();    Windows.Foundation.IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress> deploymentOperation = 
packageManager.AddPackageAsync(packageUri, null, Windows.Management.Deployment.DeploymentOptions.None);    ManualResetEvent opCompletedEvent = new ManualResetEvent(false);
// this event will be signaled when the deployment operation has completed.    deploymentOperation.Completed = (depProgress, status) => { opCompletedEvent.Set(); };

I  found that in the UWP context I needed to add UriKind.AbsoluteOrRelative parameter to the Uri instantiation.

 

When the app ran it fell over on the second line.  It said access denied.

The problem was the PackageManager. On investigation on MSDN it says PackageManager Class is not  available in Windows Store apps. Thumbs down 
But for Windows 10 it does say: Universal, introduced version 10.0.10240.0 so maybe it should work??

 

Did you set the app install capability in the app manifest? as a suggest thing to look at.

At https://msdn.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations  it says:

Other App Mangement:
The packageManagement restricted capability allows apps to manage other apps directly.
The packageQuery device capability allows apps to gather information about other apps.
These capabilities are required to access some methods and properties in the PackageManager class.

But alas:

In contrast, restricted capabilities do not require a special company account for the Store, they are not available for developers to use. Restricted capabilities are available only to apps that are developed by Microsoft and its partners. For more information about company accounts, Thumbs downThumbs down

 

Shelling Out Computer

It might be possible to run a service or task outside of the UWP app using, say, Windows.System.ProcessLauncher.RunToCompletionAsync( )
Possibly invoke AppInstall this way?