[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:
Родитель
92a6780480
Коммит
04cae2d1db
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче