diff --git a/change/react-native-windows-2020-04-29-10-09-33-tryUninstall2.json b/change/react-native-windows-2020-04-29-10-09-33-tryUninstall2.json new file mode 100644 index 00000000000..75bcac12ce6 --- /dev/null +++ b/change/react-native-windows-2020-04-29-10-09-33-tryUninstall2.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "Try uninstalling without elevation in case since it is not needed for layout installs (debug)", + "packageName": "react-native-windows", + "email": "asklar@microsoft.com", + "dependentChangeType": "patch", + "date": "2020-04-29T17:09:33.939Z" +} diff --git a/vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 b/vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 index 21b83fe5137..8e2da36859f 100644 --- a/vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 +++ b/vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 @@ -63,7 +63,12 @@ function Uninstall-App { if($package) { $pfn = $package.PackageFullName - Invoke-Expression-MayElevate "Remove-AppxPackage $pfn -ErrorAction Stop" -ErrorAction Stop + $command = "Remove-AppxPackage $pfn -ErrorAction Stop" + try { + Invoke-Expression $command + } catch { + Invoke-Expression-MayElevate $command -ErrorAction Stop + } } }