private bool UninstallApp(string packageFamilyName, string targetDevice)
        {
            // Connection info
            var connectInfo = new BuildDeployPortal.ConnectInfo(targetDevice, BuildDeployPrefs.DeviceUser, BuildDeployPrefs.DevicePassword);

            // Kick off the install
            Debug.Log("Uninstall build: " + targetDevice);
            return(BuildDeployPortal.UninstallApp(packageFamilyName, connectInfo));
        }
 bool IsAppRunning_FirstIPCheck(string appName, string targetIPs)
 {
     // Just pick the first one and use it...
     string[] IPlist = ParseIPList(targetIPs);
     if (IPlist.Length > 0)
     {
         string targetIP = FinalizeIP(IPlist[0]);
         return(BuildDeployPortal.IsAppRunning(
                    appName, new BuildDeployPortal.ConnectInfo(targetIP, BuildDeployPrefs.DeviceUser, BuildDeployPrefs.DevicePassword)));
     }
     return(false);
 }
        public void OpenLogFileForIPs(string IPs)
        {
            string packageFamilyName = CalcPackageFamilyName();

            if (string.IsNullOrEmpty(packageFamilyName))
            {
                return;
            }

            string[] ipList = ParseIPList(IPs);
            for (int i = 0; i < ipList.Length; i++)
            {
                // Use the Device Portal REST API
                BuildDeployPortal.DeviceLogFile_View(
                    packageFamilyName, new BuildDeployPortal.ConnectInfo(FinalizeIP(ipList[i]), BuildDeployPrefs.DeviceUser, BuildDeployPrefs.DevicePassword));
            }
        }
        public void KillAppOnIPs(string targetIPs)
        {
            string packageFamilyName = CalcPackageFamilyName();

            if (string.IsNullOrEmpty(packageFamilyName))
            {
                return;
            }

            string[] IPlist = ParseIPList(targetIPs);
            for (int i = 0; i < IPlist.Length; i++)
            {
                string targetIP = FinalizeIP(IPlist[i]);
                Debug.Log("Kill app on: " + targetIP);
                BuildDeployPortal.KillApp(
                    packageFamilyName, new BuildDeployPortal.ConnectInfo(targetIP, BuildDeployPrefs.DeviceUser, BuildDeployPrefs.DevicePassword));
            }
        }
        private bool InstallApp(string buildPath, string appName, string targetDevice)
        {
            // Get the appx path
            FileInfo[] files = (new DirectoryInfo(buildPath)).GetFiles("*.appx");
            files = (files.Length == 0) ? (new DirectoryInfo(buildPath)).GetFiles("*.appxbundle") : files;
            if (files.Length == 0)
            {
                Debug.LogError("No APPX found in folder build folder (" + buildPath + ")");
                return(false);
            }

            // Connection info
            var connectInfo = new BuildDeployPortal.ConnectInfo(targetDevice, BuildDeployPrefs.DeviceUser, BuildDeployPrefs.DevicePassword);

            // Kick off the install
            Debug.Log("Installing build on: " + targetDevice);
            return(BuildDeployPortal.InstallApp(files[0].FullName, connectInfo));
        }
        private void InstallAppOnDevicesList(string buildPath, bool uninstallBeforeInstall, string[] targetList)
        {
            string packageFamilyName = CalcPackageFamilyName();

            if (string.IsNullOrEmpty(packageFamilyName))
            {
                return;
            }

            for (int i = 0; i < targetList.Length; i++)
            {
                try
                {
                    bool   completedUninstall = false;
                    string IP = FinalizeIP(targetList[i]);
                    if (BuildDeployPrefs.FullReinstall &&
                        BuildDeployPortal.IsAppInstalled(packageFamilyName, new BuildDeployPortal.ConnectInfo(IP, BuildDeployPrefs.DeviceUser, BuildDeployPrefs.DevicePassword)))
                    {
                        EditorUtility.DisplayProgressBar("Installing on devices", "Uninstall (" + IP + ")", (float)i / (float)targetList.Length);
                        if (!UninstallApp(packageFamilyName, IP))
                        {
                            Debug.LogError("Uninstall failed - skipping install (" + IP + ")");
                            continue;
                        }
                        completedUninstall = true;
                    }
                    EditorUtility.DisplayProgressBar("Installing on devices", "Install (" + IP + ")", (float)(i + (completedUninstall ? 0.5f : 0.0f)) / (float)targetList.Length);
                    InstallApp(buildPath, packageFamilyName, IP);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex.ToString());
                }
            }
            EditorUtility.ClearProgressBar();
        }