Last active
August 28, 2016 23:58
-
-
Save FrayxRulez/f23672d5fbbe6b89cba2 to your computer and use it in GitHub Desktop.
Deploy UWP apps to Windows 10 Mobile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initializes MultiTargetingConnectivity with current PC culture | |
var connectivity = new MultiTargetingConnectivity(Thread.CurrentThread.CurrentUICulture.LCID); | |
var devices = connectivity.GetConnectableDevices(); | |
// Gets the first physical device attached to PC. | |
// WARNING: if more than a single device is connected to the PC deploy will fail. | |
var phone = devices.FirstOrDefault(x => !x.IsEmulator()); | |
// PhoneProductId of the app, you can find it in your Package.appxmanifest | |
var package = Guid.Parse("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); | |
var device = phone.Connect(true); | |
try | |
{ | |
// If application is already installed simply uninstall it. | |
if (device.IsApplicationInstalled(package)) | |
{ | |
device.GetApplication(package).Uninstall(); | |
} | |
} | |
catch { } | |
try | |
{ | |
// Installs the app to the device. | |
// Parameters are: | |
// Guid productId = PhoneProductId | |
// Guid instanceId = PhoneProductId | |
// string applicationGenre = "32", that means "Sideload" | |
// string iconPath = "2" if the package extension is "appx" | |
// string xapPackage = absolute path of the package | |
var app = device.InstallApplication(package, package, "32", "2", full_path_to_the_file); | |
} | |
finally | |
{ | |
// Disconnect to the current device. | |
// IMPORTANT: call this method or you have to reboot the phone to apply changes. | |
device.Disconnect(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Full explanation at my blog here: https://frayxrulez.wordpress.com/2015/06/18/how-to-sideload-uwp-apps-to-windows-10-mobile/