From 7b4cf907a41402e838cfea77611d1f8142eeb891 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Wed, 1 Apr 2020 14:42:54 -0700 Subject: [PATCH 1/7] Fix crash when calling measure on non-framework element (#4473) * Fix crash when calling measure on non-framework element * Change files --- ...-native-windows-2020-04-01-13-40-22-devtoolscrash.json | 8 ++++++++ vnext/ReactUWP/Modules/NativeUIManager.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 change/react-native-windows-2020-04-01-13-40-22-devtoolscrash.json diff --git a/change/react-native-windows-2020-04-01-13-40-22-devtoolscrash.json b/change/react-native-windows-2020-04-01-13-40-22-devtoolscrash.json new file mode 100644 index 00000000000..bcf149bc7df --- /dev/null +++ b/change/react-native-windows-2020-04-01-13-40-22-devtoolscrash.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "Fix crash when calling measure on non-framework element", + "packageName": "react-native-windows", + "email": "acoates@microsoft.com", + "dependentChangeType": "patch", + "date": "2020-04-01T20:40:22.490Z" +} \ No newline at end of file diff --git a/vnext/ReactUWP/Modules/NativeUIManager.cpp b/vnext/ReactUWP/Modules/NativeUIManager.cpp index 4b743966245..9744d616741 100644 --- a/vnext/ReactUWP/Modules/NativeUIManager.cpp +++ b/vnext/ReactUWP/Modules/NativeUIManager.cpp @@ -907,7 +907,7 @@ void NativeUIManager::measure( ShadowNodeBase &node = static_cast(shadowNode); auto view = node.GetView(); - auto feView = view.as(); + auto feView = view.try_as(); if (feView == nullptr) { callback(args); return; From 49af4c71ab07264496de1f1daf289d2b54a83d63 Mon Sep 17 00:00:00 2001 From: Vladimir Morozov Date: Tue, 31 Mar 2020 21:56:37 -0700 Subject: [PATCH 2/7] Fix new project build (#4469) * Set $(ReactNativeWindowsDir) before it is used * Change files --- ...ve-windows-2020-03-31-20-25-48-FixNewProjectBuild.json | 8 ++++++++ vnext/Directory.Build.props | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 change/react-native-windows-2020-03-31-20-25-48-FixNewProjectBuild.json diff --git a/change/react-native-windows-2020-03-31-20-25-48-FixNewProjectBuild.json b/change/react-native-windows-2020-03-31-20-25-48-FixNewProjectBuild.json new file mode 100644 index 00000000000..e12f7359153 --- /dev/null +++ b/change/react-native-windows-2020-03-31-20-25-48-FixNewProjectBuild.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "Set $(ReactNativeWindowsDir) before it is used", + "packageName": "react-native-windows", + "email": "vmorozov@microsoft.com", + "dependentChangeType": "patch", + "date": "2020-04-01T03:25:48.573Z" +} \ No newline at end of file diff --git a/vnext/Directory.Build.props b/vnext/Directory.Build.props index 87b6500ca8b..d2a7137eea2 100644 --- a/vnext/Directory.Build.props +++ b/vnext/Directory.Build.props @@ -13,6 +13,9 @@ + + + $(MSBuildProjectName) From fc074f8d2a8bbc32b2700079963e588a3aff3952 Mon Sep 17 00:00:00 2001 From: Jon Thysell Date: Tue, 31 Mar 2020 14:45:03 -0700 Subject: [PATCH 3/7] Update MSBuild ADO Tasks to use MSBuild x64 (#4462) * Removed x86 override for msbuild tasks in CI, publish * Switch from MSBuild to VSBuild * Added `false` to C# app projects to fix build issues with msbuild x64 * Added `/p:AppxGeneratePrisForPortableLibrariesEnabled=false` for testcli build task --- .ado/publish.yml | 1 - .ado/templates/build-rnw.yml | 11 +++++--- .ado/templates/react-native-init.yml | 14 +++++++---- .ado/windows-vs-pr.yml | 25 +++++++++++-------- ...indows-2020-03-31-10-16-02-msbuildx64.json | 8 ++++++ .../ReactUWPTestApp/ReactUWPTestApp.csproj | 1 + .../windows/SampleAppCS/SampleAppCS.csproj | 1 + ...osoft.ReactNative.Managed.UnitTests.csproj | 1 + .../templates/cs/proj/MyApp.csproj | 4 +-- 9 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 change/react-native-windows-2020-03-31-10-16-02-msbuildx64.json diff --git a/.ado/publish.yml b/.ado/publish.yml index 4952ad60660..772bb76280e 100644 --- a/.ado/publish.yml +++ b/.ado/publish.yml @@ -149,7 +149,6 @@ jobs: - template: templates/build-rnw.yml parameters: project: vnext/ReactWindows-Universal.sln - msBuildArchitecture: x86 # Necessary to build C# unit tests vsComponents: $(VsComponents),Microsoft.VisualStudio.Component.VC.v141.ARM,Microsoft.VisualStudio.Component.VC.v141.ARM64 - template: templates/publish-build-artifacts-for-nuget.yml diff --git a/.ado/templates/build-rnw.yml b/.ado/templates/build-rnw.yml index bc2b612d10a..2a0260822fd 100644 --- a/.ado/templates/build-rnw.yml +++ b/.ado/templates/build-rnw.yml @@ -34,17 +34,20 @@ steps: restoreDirectory: packages/ verbosityRestore: Detailed # Options: quiet, normal, detailed - - task: MSBuild@1 - displayName: MSBuild ${{parameters.project}} + - task: VSBuild@1 + displayName: VSBuild ${{parameters.project}} inputs: solution: ${{parameters.project }} - msbuildVersion: ${{parameters.msbuildVersion}} + vsVersion: ${{parameters.msbuildVersion}} msbuildArchitecture: ${{parameters.msBuildArchitecture}} platform: $(BuildPlatform) configuration: $(BuildConfiguration) + clean: false # Optional + maximumCpuCount: false # Optional + restoreNugetPackages: false # Optional createLogFile: true logFileVerbosity: detailed - msbuildArguments: + msbuildArgs: /p:PreferredToolArchitecture=${{parameters.preferredToolArchitecture}} /p:PlatformToolset=${{parameters.platformToolset}} /p:BaseIntDir=$(BaseIntDir) diff --git a/.ado/templates/react-native-init.yml b/.ado/templates/react-native-init.yml index d78cdbb2ae7..d9e7f73a04d 100644 --- a/.ado/templates/react-native-init.yml +++ b/.ado/templates/react-native-init.yml @@ -93,20 +93,24 @@ steps: -Components ${{ parameters.vsComponents }} condition: and(ne('${{parameters.vsComponents}}', ''), eq(variables['VmImage'], 'windows-2019')) - - task: MSBuild@1 - displayName: MSBuild - testcli + - task: VSBuild@1 + displayName: VSBuild - testcli inputs: solution: $(Agent.BuildDirectory)\testcli\windows\testcli.sln - msbuildVersion: $(MSBuildVersion) # Optional. Options: latest, 16.0, 15.0, 14.0, 12.0, 4.0 - msbuildArchitecture: x86 # $(MSBuildArchitecture) # Optional. Options: x86, x64 + vsVersion: $(MSBuildVersion) # Optional. Options: latest, 16.0, 15.0, 14.0, 12.0, 4.0 + msbuildArchitecture: $(MSBuildArchitecture) # Optional. Options: x86, x64 platform: ${{ parameters.platform }} # Optional configuration: ${{ parameters.configuration }} # Optional + clean: false # Optional + maximumCpuCount: false # Optional + restoreNugetPackages: false # Optional createLogFile: true logFileVerbosity: detailed - msbuildArguments: + msbuildArgs: /p:PreferredToolArchitecture=$(MSBuildPreferredToolArchitecture) /p:PlatformToolset=$(MSBuildPlatformToolset) /p:BaseIntDir=$(BaseIntDir) + /p:AppxGeneratePrisForPortableLibrariesEnabled=false - task: PublishBuildArtifacts@1 condition: succeededOrFailed() diff --git a/.ado/windows-vs-pr.yml b/.ado/windows-vs-pr.yml index 53ae691cd33..56a40e33e2d 100644 --- a/.ado/windows-vs-pr.yml +++ b/.ado/windows-vs-pr.yml @@ -70,7 +70,6 @@ jobs: parameters: yarnBuildCmd: build project: vnext/ReactWindows-Universal.sln - msBuildArchitecture: x86 # Necessary to build C# unit tests vsComponents: $(VsComponents),Microsoft.VisualStudio.Component.VC.v141.ARM,Microsoft.VisualStudio.Component.VC.v141.ARM64 - task: VSTest@2 @@ -134,19 +133,21 @@ jobs: restoreSolution: packages/playground/windows/Playground.sln verbosityRestore: Detailed # Options: quiet, normal, detailed - - task: MSBuild@1 - displayName: MSBuild - Playground + - task: VSBuild@1 + displayName: VSBuild - Playground inputs: solution: packages/playground/windows/Playground.sln - msbuildVersion: $(MSBuildVersion) # Optional. Options: latest, 16.0, 15.0, 14.0, 12.0, 4.0 + vsVersion: $(MSBuildVersion) # Optional. Options: latest, 16.0, 15.0, 14.0, 12.0, 4.0 msbuildArchitecture: $(MSBuildArchitecture) # Optional. Options: x86, x64 platform: $(BuildPlatform) # Optional configuration: $(BuildConfiguration) # Optional - msbuildArguments: + clean: true # Optional + maximumCpuCount: false # Optional + restoreNugetPackages: false # Optional + msbuildArgs: /p:PreferredToolArchitecture=$(MSBuildPreferredToolArchitecture) /p:PlatformToolset=$(MSBuildPlatformToolset) /p:BaseIntDir=$(BaseIntDir) - clean: true # Optional - task: NuGetCommand@2 displayName: NuGet restore - Playground Win32 @@ -155,19 +156,21 @@ jobs: restoreSolution: packages/playground/windows/Playground-Win32.sln verbosityRestore: Detailed # Options: quiet, normal, detailed - - task: MSBuild@1 - displayName: MSBuild - Playground Win32 + - task: VSBuild@1 + displayName: VSBuild - Playground Win32 inputs: solution: packages/playground/windows/Playground-Win32.sln - msbuildVersion: $(MSBuildVersion) # Optional. Options: latest, 16.0, 15.0, 14.0, 12.0, 4.0 + vsVersion: $(MSBuildVersion) # Optional. Options: latest, 16.0, 15.0, 14.0, 12.0, 4.0 msbuildArchitecture: $(MSBuildArchitecture) # Optional. Options: x86, x64 platform: $(BuildPlatform) # Optional configuration: $(BuildConfiguration) # Optional - msbuildArguments: + clean: true # Optional + maximumCpuCount: false # Optional + restoreNugetPackages: false # Optional + msbuildArgs: /p:PreferredToolArchitecture=$(MSBuildPreferredToolArchitecture) /p:PlatformToolset=$(MSBuildPlatformToolset) /p:BaseIntDir=$(BaseIntDir) - clean: true # Optional - task: CmdLine@2 displayName: Create Playground bundle diff --git a/change/react-native-windows-2020-03-31-10-16-02-msbuildx64.json b/change/react-native-windows-2020-03-31-10-16-02-msbuildx64.json new file mode 100644 index 00000000000..01adc422051 --- /dev/null +++ b/change/react-native-windows-2020-03-31-10-16-02-msbuildx64.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "Update MSBuild Tasks to use MSBuild x64", + "packageName": "react-native-windows", + "email": "jthysell@microsoft.com", + "dependentChangeType": "patch", + "date": "2020-03-31T17:16:02.126Z" +} \ No newline at end of file diff --git a/packages/E2ETest/windows/ReactUWPTestApp/ReactUWPTestApp.csproj b/packages/E2ETest/windows/ReactUWPTestApp/ReactUWPTestApp.csproj index a9716bdfeca..d044ace3330 100644 --- a/packages/E2ETest/windows/ReactUWPTestApp/ReactUWPTestApp.csproj +++ b/packages/E2ETest/windows/ReactUWPTestApp/ReactUWPTestApp.csproj @@ -20,6 +20,7 @@ FCDD40CD2A4E90DD1F10E5C04D5A958E6B5311CA ReactUWPTestApp_TemporaryKey.pfx True + false true diff --git a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/SampleAppCS.csproj b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/SampleAppCS.csproj index a5c6cb7818d..ee5da7af485 100644 --- a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/SampleAppCS.csproj +++ b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/SampleAppCS.csproj @@ -18,6 +18,7 @@ {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} true false + false 7.0 diff --git a/vnext/Microsoft.ReactNative.Managed.UnitTests/Microsoft.ReactNative.Managed.UnitTests.csproj b/vnext/Microsoft.ReactNative.Managed.UnitTests/Microsoft.ReactNative.Managed.UnitTests.csproj index 2eca04c8739..bf6f8662bd1 100644 --- a/vnext/Microsoft.ReactNative.Managed.UnitTests/Microsoft.ReactNative.Managed.UnitTests.csproj +++ b/vnext/Microsoft.ReactNative.Managed.UnitTests/Microsoft.ReactNative.Managed.UnitTests.csproj @@ -18,6 +18,7 @@ {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} $(VisualStudioVersion) false + false true diff --git a/vnext/local-cli/generator-windows/templates/cs/proj/MyApp.csproj b/vnext/local-cli/generator-windows/templates/cs/proj/MyApp.csproj index 340c762ba93..a524ebde8ec 100644 --- a/vnext/local-cli/generator-windows/templates/cs/proj/MyApp.csproj +++ b/vnext/local-cli/generator-windows/templates/cs/proj/MyApp.csproj @@ -1,9 +1,6 @@  - - SomeValue - Debug x86 @@ -23,6 +20,7 @@ <%=name%>_TemporaryKey.pfx <%=certificateThumbprint%> password + false true From e5a523754a71d0c7d934a941107ccd4457d24eae Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Fri, 27 Mar 2020 13:25:22 -0700 Subject: [PATCH 4/7] Some Direct Debugging fixes (#4440) * Fix direct debugging * formatting * Change files --- ...native-windows-2020-03-27-11-52-38-dd.json | 8 +++++ .../ReactHost/ReactInstanceWin.cpp | 33 ++++++++++--------- .../Views/ReactRootControl.cpp | 4 ++- vnext/ReactWindowsCore/DevSettings.h | 2 ++ vnext/Shared/OInstance.cpp | 2 +- 5 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 change/react-native-windows-2020-03-27-11-52-38-dd.json diff --git a/change/react-native-windows-2020-03-27-11-52-38-dd.json b/change/react-native-windows-2020-03-27-11-52-38-dd.json new file mode 100644 index 00000000000..5a5e620a47f --- /dev/null +++ b/change/react-native-windows-2020-03-27-11-52-38-dd.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "Fix direct debugging", + "packageName": "react-native-windows", + "email": "acoates@microsoft.com", + "dependentChangeType": "patch", + "date": "2020-03-27T18:52:38.219Z" +} \ No newline at end of file diff --git a/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp b/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp index 373fc4c9641..6494964c877 100644 --- a/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +++ b/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp @@ -171,6 +171,7 @@ void ReactInstanceWin::Initialize() noexcept { devSettings->debuggerPort = m_options.DeveloperSettings.DebuggerPort; devSettings->debuggerRuntimeName = m_options.DeveloperSettings.DebuggerRuntimeName; devSettings->useWebDebugger = m_options.DeveloperSettings.UseWebDebugger; + devSettings->useFastRefresh = m_options.DeveloperSettings.UseFastRefresh; // devSettings->memoryTracker = GetMemoryTracker(); devSettings->bundleRootPath = m_options.BundleRootPath.empty() ? "ms-appx:///Bundle/" : m_options.BundleRootPath; @@ -313,7 +314,22 @@ void ReactInstanceWin::LoadJSBundles() noexcept { // The OnReactInstanceLoaded internally only accepts the first call and ignores others. // - if (!m_options.DeveloperSettings.UseWebDebugger) { + if (m_options.DeveloperSettings.UseWebDebugger || m_options.DeveloperSettings.UseFastRefresh) { + // Getting bundle from the packager, so do everything async. + auto instanceWrapper = m_instanceWrapper.LoadWithLock(); + instanceWrapper->loadBundle(Mso::Copy(m_options.Identity)); + + m_jsMessageThread.Load()->runOnQueue([ + weakThis = Mso::WeakPtr{this}, + loadCallbackGuard = Mso::MakeMoveOnCopyWrapper(LoadedCallbackGuard{*this}) + ]() noexcept { + if (auto strongThis = weakThis.GetStrongPtr()) { + if (strongThis->State() != ReactInstanceState::HasError) { + strongThis->OnReactInstanceLoaded(Mso::ErrorCode{}); + } + } + }); + } else { m_jsMessageThread.Load()->runOnQueue([ weakThis = Mso::WeakPtr{this}, loadCallbackGuard = Mso::MakeMoveOnCopyWrapper(LoadedCallbackGuard{*this}) @@ -339,21 +355,6 @@ void ReactInstanceWin::LoadJSBundles() noexcept { strongThis->OnReactInstanceLoaded(Mso::ErrorCode{}); } }); - } else { - // Web Debugging - auto instanceWrapper = m_instanceWrapper.LoadWithLock(); - instanceWrapper->loadBundle(Mso::Copy(m_options.Identity)); - - m_jsMessageThread.Load()->runOnQueue([ - weakThis = Mso::WeakPtr{this}, - loadCallbackGuard = Mso::MakeMoveOnCopyWrapper(LoadedCallbackGuard{*this}) - ]() noexcept { - if (auto strongThis = weakThis.GetStrongPtr()) { - if (strongThis->State() != ReactInstanceState::HasError) { - strongThis->OnReactInstanceLoaded(Mso::ErrorCode{}); - } - } - }); } } diff --git a/vnext/Microsoft.ReactNative/Views/ReactRootControl.cpp b/vnext/Microsoft.ReactNative/Views/ReactRootControl.cpp index fc6be64b0c0..0574a0762d3 100644 --- a/vnext/Microsoft.ReactNative/Views/ReactRootControl.cpp +++ b/vnext/Microsoft.ReactNative/Views/ReactRootControl.cpp @@ -519,6 +519,7 @@ void ReactRootControl::ShowDeveloperMenu() noexcept { winrt::auto_revoke, [this](auto const & /*sender*/, winrt::RoutedEventArgs const & /*args*/) noexcept { DismissDeveloperMenu(); m_useWebDebugger = !m_useWebDebugger; + m_directDebugging = false; // Remote debugging is incompatible with direct debugging ReloadHost(); }); @@ -527,11 +528,12 @@ void ReactRootControl::ShowDeveloperMenu() noexcept { winrt::auto_revoke, [this](auto const & /*sender*/, winrt::RoutedEventArgs const & /*args*/) noexcept { DismissDeveloperMenu(); m_directDebugging = !m_directDebugging; + m_useWebDebugger = false; // Remote debugging is incompatible with direct debugging ReloadHost(); }); breakOnNextLineText.Text(m_breakOnNextLine ? L"Disable Break on First Line" : L"Enable Break on First Line"); - m_breakOnNextLineRevoker = directDebugButton.Click( + m_breakOnNextLineRevoker = breakOnNextLineButton.Click( winrt::auto_revoke, [this](auto const & /*sender*/, winrt::RoutedEventArgs const & /*args*/) noexcept { DismissDeveloperMenu(); m_breakOnNextLine = !m_breakOnNextLine; diff --git a/vnext/ReactWindowsCore/DevSettings.h b/vnext/ReactWindowsCore/DevSettings.h index 28ed1f70887..44808a5e4d9 100644 --- a/vnext/ReactWindowsCore/DevSettings.h +++ b/vnext/ReactWindowsCore/DevSettings.h @@ -81,6 +81,8 @@ struct DevSettings { /// is loaded. bool useWebDebugger{false}; + bool useFastRefresh{false}; + // Enables ChakraCore console redirection to debugger bool debuggerConsoleRedirection{false}; diff --git a/vnext/Shared/OInstance.cpp b/vnext/Shared/OInstance.cpp index 0e617ef27df..35b3552dfff 100644 --- a/vnext/Shared/OInstance.cpp +++ b/vnext/Shared/OInstance.cpp @@ -510,7 +510,7 @@ void InstanceImpl::loadBundleInternal(std::string &&jsBundleRelativePath, bool s m_devSettings->errorCallback(e.what()); return; } - } else if (m_devSettings->liveReloadCallback != nullptr) { + } else if (m_devSettings->liveReloadCallback != nullptr || m_devSettings->useFastRefresh) { auto jsBundleString = m_devManager->GetJavaScriptFromServer( m_devSettings->debugHost, jsBundleRelativePath, m_devSettings->platformName); From d356482093fca1c06f22bed0057675650cc03382 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Thu, 26 Mar 2020 12:49:32 -0700 Subject: [PATCH 5/7] Add timeout to certificate generation on project init (#4430) * Add a timeout to catch hangs during cert generation * Change files --- ...ndows-2020-03-26-09-13-41-certtimeout.json | 8 ++++++ vnext/local-cli/generator-windows/index.js | 28 ++++++++----------- 2 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 change/react-native-windows-2020-03-26-09-13-41-certtimeout.json diff --git a/change/react-native-windows-2020-03-26-09-13-41-certtimeout.json b/change/react-native-windows-2020-03-26-09-13-41-certtimeout.json new file mode 100644 index 00000000000..a5ae359f98b --- /dev/null +++ b/change/react-native-windows-2020-03-26-09-13-41-certtimeout.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "Add a timeout to catch hangs during cert generation", + "packageName": "react-native-windows", + "email": "acoates@microsoft.com", + "dependentChangeType": "patch", + "date": "2020-03-26T16:13:40.983Z" +} \ No newline at end of file diff --git a/vnext/local-cli/generator-windows/index.js b/vnext/local-cli/generator-windows/index.js index 6b66a15a385..80eeaaddbb3 100644 --- a/vnext/local-cli/generator-windows/index.js +++ b/vnext/local-cli/generator-windows/index.js @@ -20,24 +20,20 @@ function generateCertificate(srcPath, destPath, newProjectName, currentUser) { console.log('Generating self-signed certificate...'); let toCopyTempKey = false; if (os.platform() === 'win32') { - const certGenCommand = [ - `$cert = New-SelfSignedCertificate -KeyUsage DigitalSignature -KeyExportPolicy Exportable -Subject "CN=${currentUser}" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}Subject Type:End Entity") -CertStoreLocation "Cert:\\CurrentUser\\My"`, - '$pwd = ConvertTo-SecureString -String password -Force -AsPlainText', - `New-Item -ErrorAction Ignore -ItemType directory -Path ${path.join(windowsDir, newProjectName)}`, - `Export-PfxCertificate -Cert "cert:\\CurrentUser\\My\\$($cert.Thumbprint)" -FilePath ${path.join(windowsDir, newProjectName, newProjectName)}_TemporaryKey.pfx -Password $pwd`, - '$cert.Thumbprint', - ]; - const certGenProcess = childProcess.spawnSync('powershell', ['-command', certGenCommand.join(';')]); - - if (certGenProcess.status === 0) { - const certGenProcessOutput = certGenProcess.stdout.toString().trim().split('\n'); + try { + const timeout = 10000; // 10 seconds; + const thumbprint = childProcess.execSync(`powershell -command "Write-Output (New-SelfSignedCertificate -KeyUsage DigitalSignature -KeyExportPolicy Exportable -Subject 'CN=${currentUser}' -TextExtension @('2.5.29.37={text}1.3.6.1.5.5.7.3.3', '2.5.29.19={text}Subject Type:End Entity') -CertStoreLocation 'Cert:\\CurrentUser\\My').Thumbprint"`, {timeout}).toString().trim(); + if (!fs.existsSync(path.join(windowsDir, newProjectName))) { + fs.createDir(path.join(windowsDir, newProjectName)); + } + childProcess.execSync(`powershell -command "$pwd = (ConvertTo-SecureString -String password -Force -AsPlainText); Export-PfxCertificate -Cert 'cert:\\CurrentUser\\My\\${thumbprint}' -FilePath ${path.join(windowsDir, newProjectName, newProjectName)}_TemporaryKey.pfx -Password $pwd"`, {timeout}); console.log(chalk.green('Self-signed certificate generated successfully.')); - return certGenProcessOutput[certGenProcessOutput.length - 1]; + return thumbprint; + } catch (err) { + console.log(chalk.yellow('Failed to generate Self-signed certificate. Using Default Certificate. Use Visual Studio to renew it.')); + toCopyTempKey = true; + } } else { - console.log(chalk.yellow('Failed to generate Self-signed certificate. Using Default Certificate. Use Visual Studio to renew it.')); - toCopyTempKey = true; - } - } else { console.log(chalk.yellow('Using Default Certificate. Use Visual Studio to renew it.')); toCopyTempKey = true; } From 2e4363653ab36573629960501deb288b115ca785 Mon Sep 17 00:00:00 2001 From: "Andrew Coates (REDMOND)" Date: Fri, 3 Apr 2020 09:03:46 -0700 Subject: [PATCH 6/7] Update change files to use patch version bumping --- .../react-native-windows-2020-03-26-09-13-41-certtimeout.json | 2 +- change/react-native-windows-2020-03-27-11-52-38-dd.json | 2 +- change/react-native-windows-2020-03-31-10-16-02-msbuildx64.json | 2 +- ...t-native-windows-2020-03-31-20-25-48-FixNewProjectBuild.json | 2 +- .../react-native-windows-2020-04-01-13-40-22-devtoolscrash.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/change/react-native-windows-2020-03-26-09-13-41-certtimeout.json b/change/react-native-windows-2020-03-26-09-13-41-certtimeout.json index a5ae359f98b..5a03cb8d194 100644 --- a/change/react-native-windows-2020-03-26-09-13-41-certtimeout.json +++ b/change/react-native-windows-2020-03-26-09-13-41-certtimeout.json @@ -1,5 +1,5 @@ { - "type": "prerelease", + "type": "patch", "comment": "Add a timeout to catch hangs during cert generation", "packageName": "react-native-windows", "email": "acoates@microsoft.com", diff --git a/change/react-native-windows-2020-03-27-11-52-38-dd.json b/change/react-native-windows-2020-03-27-11-52-38-dd.json index 5a5e620a47f..5b09b29dd76 100644 --- a/change/react-native-windows-2020-03-27-11-52-38-dd.json +++ b/change/react-native-windows-2020-03-27-11-52-38-dd.json @@ -1,5 +1,5 @@ { - "type": "prerelease", + "type": "patch", "comment": "Fix direct debugging", "packageName": "react-native-windows", "email": "acoates@microsoft.com", diff --git a/change/react-native-windows-2020-03-31-10-16-02-msbuildx64.json b/change/react-native-windows-2020-03-31-10-16-02-msbuildx64.json index 01adc422051..38daba85ee3 100644 --- a/change/react-native-windows-2020-03-31-10-16-02-msbuildx64.json +++ b/change/react-native-windows-2020-03-31-10-16-02-msbuildx64.json @@ -1,5 +1,5 @@ { - "type": "prerelease", + "type": "patch", "comment": "Update MSBuild Tasks to use MSBuild x64", "packageName": "react-native-windows", "email": "jthysell@microsoft.com", diff --git a/change/react-native-windows-2020-03-31-20-25-48-FixNewProjectBuild.json b/change/react-native-windows-2020-03-31-20-25-48-FixNewProjectBuild.json index e12f7359153..02b05fe9518 100644 --- a/change/react-native-windows-2020-03-31-20-25-48-FixNewProjectBuild.json +++ b/change/react-native-windows-2020-03-31-20-25-48-FixNewProjectBuild.json @@ -1,5 +1,5 @@ { - "type": "prerelease", + "type": "patch", "comment": "Set $(ReactNativeWindowsDir) before it is used", "packageName": "react-native-windows", "email": "vmorozov@microsoft.com", diff --git a/change/react-native-windows-2020-04-01-13-40-22-devtoolscrash.json b/change/react-native-windows-2020-04-01-13-40-22-devtoolscrash.json index bcf149bc7df..6aadcc68e2e 100644 --- a/change/react-native-windows-2020-04-01-13-40-22-devtoolscrash.json +++ b/change/react-native-windows-2020-04-01-13-40-22-devtoolscrash.json @@ -1,5 +1,5 @@ { - "type": "prerelease", + "type": "patch", "comment": "Fix crash when calling measure on non-framework element", "packageName": "react-native-windows", "email": "acoates@microsoft.com", From 810f03cd497ebe06170da3db294ff60c679fa5e7 Mon Sep 17 00:00:00 2001 From: "Andrew Coates (REDMOND)" Date: Fri, 3 Apr 2020 09:52:10 -0700 Subject: [PATCH 7/7] publishing fix --- .ado/setVersionEnvVars.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.ado/setVersionEnvVars.js b/.ado/setVersionEnvVars.js index 49a8cccbca8..c7c6b0c24e8 100644 --- a/.ado/setVersionEnvVars.js +++ b/.ado/setVersionEnvVars.js @@ -8,7 +8,8 @@ const pkgJsonPath = path.resolve(__dirname, "../vnext/package.json"); // Helper to format npmVersion in a way that the Version.rc resource files want it function npmVersionToRcVersion(npmVersion) { let groups = npmVersion.split(/[\.-]/); - return `${groups[0]},${groups[1]},${groups[2]},${groups[4]}`; + const [major,minor,patch,_junk,prerelease] = groups; + return `${major},${minor},${patch},${prerelease ? prerelease : '0'}`; } let pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));