diff --git a/.ado/templates/e2e-test-job.yml b/.ado/templates/e2e-test-job.yml index 6c0b7e41a47..27ce3dce06c 100644 --- a/.ado/templates/e2e-test-job.yml +++ b/.ado/templates/e2e-test-job.yml @@ -95,7 +95,7 @@ jobs: - task: CmdLine@2 displayName: run-windows inputs: - script: react-native run-windows --no-packager --arch ${{ parameters.BuildPlatform }} --release --bundle --logging --force + script: react-native run-windows --no-packager --arch ${{ parameters.BuildPlatform }} --release --bundle --logging workingDirectory: packages/E2ETest # Wait for app to launch. A workaround to avoid WinAppDriver error: Failed to locate opened application window with appId diff --git a/change/react-native-windows-2019-10-17-09-21-39-AppPackageFix.json b/change/react-native-windows-2019-10-17-09-21-39-AppPackageFix.json new file mode 100644 index 00000000000..f50fa82bd34 --- /dev/null +++ b/change/react-native-windows-2019-10-17-09-21-39-AppPackageFix.json @@ -0,0 +1,9 @@ +{ + "type": "prerelease", + "comment": "Fix run-windows app installation hang", + "packageName": "react-native-windows", + "email": "dida@ntdev.microsoft.com", + "commit": "6c1f607816162e9beb50f942a0babe9229ac7d68", + "date": "2019-10-17T16:21:39.147Z", + "file": "D:\\react-native-windows\\change\\react-native-windows-2019-10-17-09-21-39-AppPackageFix.json" +} \ No newline at end of file diff --git a/vnext/local-cli/runWindows/runWindows.js b/vnext/local-cli/runWindows/runWindows.js index b261190ebaa..328b9a8552f 100644 --- a/vnext/local-cli/runWindows/runWindows.js +++ b/vnext/local-cli/runWindows/runWindows.js @@ -93,7 +93,6 @@ runWindows({ * no-launch: Boolean - Do not launch the app after deployment * no-build: Boolean - Do not build the solution * no-deploy: Boolean - Do not deploy the app - * force: Boolean - same as Add-AppDevPackage.ps1 Force flag */ module.exports = { name: 'run-windows', @@ -146,11 +145,6 @@ module.exports = { 'Enable Bundle configuration and it would be ReleaseBundle/DebugBundle other than Release/Debug', default: false, }, - { - command: '--force', - description: 'same as Add-AppDevPackage.ps1 Force flag', - default: false, - }, { command: '--no-launch', description: 'Do not launch the app after deployment', diff --git a/vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 b/vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 index fd710e9280a..68a76ce1874 100644 --- a/vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 +++ b/vnext/local-cli/runWindows/utils/WindowsStoreAppUtils.ps1 @@ -81,6 +81,16 @@ function CheckIfNeedDeveloperLicense return $Result } +function EnableDevmode { + $RegistryKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" + + if (-not(Test-Path -Path $RegistryKeyPath)) { + New-Item -Path $RegistryKeyPath -ItemType Directory -Force + } + + Set-ItemProperty -Path $RegistryKeyPath -Name AllowDevelopmentWithoutDevLicense -Value 1 +} + # # Checks whether the package certificate must be installed on the machine. # diff --git a/vnext/local-cli/runWindows/utils/deploy.js b/vnext/local-cli/runWindows/utils/deploy.js index c1afbb50e93..639375eb2b2 100644 --- a/vnext/local-cli/runWindows/utils/deploy.js +++ b/vnext/local-cli/runWindows/utils/deploy.js @@ -158,21 +158,31 @@ async function deployToDesktop(options, verbose) { newSpinner(removingText), removingText, 'powershell', - `-ExecutionPolicy RemoteSigned Import-Module "${windowsStoreAppUtils}" ; Uninstall-App ${appName}`.split( + `-NoProfile -ExecutionPolicy RemoteSigned Import-Module "${windowsStoreAppUtils}" ; Uninstall-App ${appName}`.split( ' ', ), verbose, ); + const devmodeText = 'Enabling Developer Mode'; + const devmodeEnable = `-NoProfile -ExecutionPolicy RemoteSigned Import-Module "${windowsStoreAppUtils}"; EnableDevmode "${script}"`; + + await commandWithProgress( + newSpinner(devmodeText), + devmodeText, + 'powershell', + devmodeEnable.split(' '), + verbose, + ); + const installingText = 'Installing new version of the app'; - const installApp = `-ExecutionPolicy RemoteSigned Import-Module "${windowsStoreAppUtils}"; Install-App "${script}"`; - const installAppCmd = options.force ? installApp + ' -Force' : installApp; + const installApp = `-NoProfile -ExecutionPolicy RemoteSigned Import-Module "${windowsStoreAppUtils}"; Install-App "${script}" -Force`; await commandWithProgress( newSpinner(installingText), installingText, 'powershell', - installAppCmd.split(' '), + installApp.split(' '), verbose, );