[DeviceTests] Uninstall appx in try/catch

This should check if the app is installed first before it tries to uninstall, and run in a try/catch block to ensure it doesn't fail the build.
This commit is contained in:
Jonathan Dick 2018-04-10 20:16:17 -04:00 коммит произвёл GitHub
Родитель 92a6780480
Коммит 04cae2d1db
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 10 добавлений и 9 удалений

Просмотреть файл

@ -259,15 +259,16 @@ Task ("test-uwp-emu")
.WithCriteria(IsRunningOnWindows())
.Does (() =>
{
// var uninstallPS = new Action (() => {
// StartProcess ("powershell", $"Remove-AppxPackage -Package (Get-AppxPackage -Name {UWP_PACKAGE_ID}).PackageFullName");
// });
// try {
// // Try to uninstall the app if it exists from before
// uninstallPS();
// } catch { }
var uninstallPS = new Action (() => {
try {
StartProcess ("powershell",
$"$app = Get-AppxPackage -Name {UWP_PACKAGE_ID}; if ($app) { Remove-AppxPackage -Package $app.PackageFullName }");
} catch { }
});
// Try to uninstall the app if it exists from before
uninstallPS();
// Install the appx
var appxBundlePath = GetFiles("./**/AppPackages/**/*.appxbundle").First ();
Information("Installing appx: {0}", appxBundlePath);
@ -289,7 +290,7 @@ Task ("test-uwp-emu")
AddPlatformToTestResults(UWP_TEST_RESULTS_PATH, "UWP");
// Uninstall the app (this will terminate it too)
// uninstallPS();
uninstallPS();
});
RunTarget(TARGET);