diff --git a/.ado/publish.yml b/.ado/publish.yml index 5df81de516a..249427d156a 100644 --- a/.ado/publish.yml +++ b/.ado/publish.yml @@ -4,11 +4,17 @@ variables: - template: variables/msbuild.yml - template: variables/vs2019.yml +schedules: +- cron: "0 0 * * *" + displayName: Nightly publish build + branches: + include: + - master + trigger: batch: true branches: include: - - master - "*-stable" pr: none diff --git a/.ado/templates/react-native-init.yml b/.ado/templates/react-native-init.yml index ef409391898..d6a92173390 100644 --- a/.ado/templates/react-native-init.yml +++ b/.ado/templates/react-native-init.yml @@ -65,7 +65,7 @@ steps: inputs: artifactName: TestMSRNNuget.${{ parameters.platform }}.${{ parameters.configuration }} downloadPath: $(System.DefaultWorkingDirectory) - condition: eq('true', ${{ parameters.experimentalNugetDependency }}) + condition: and(succeeded(), eq('true', ${{ parameters.experimentalNugetDependency }})) - task: CmdLine@2 displayName: Init new project @@ -84,14 +84,20 @@ steps: inputs: targetType: inline script: | - Install-Package Microsoft.ReactNative -Source $(System.DefaultWorkingDirectory)/TestMSRNNuget.${{ parameters.platform }}.${{ parameters.configuration }} -Destination $(Agent.BuildDirectory)\testcli\windows\packages - condition: eq('true', ${{ parameters.experimentalNugetDependency }}) - - - task: NuGetCommand@2 - displayName: NuGet restore testcli - inputs: - command: restore - restoreSolution: $(Agent.BuildDirectory)\testcli\windows\testcli.sln + Install-Package Microsoft.ReactNative -Source $(System.DefaultWorkingDirectory)/TestMSRNNuget.${{ parameters.platform }}.${{ parameters.configuration }} -Destination $(Agent.BuildDirectory)\testcli\localNugets + $xml = [xml](gc $(Agent.BuildDirectory)\testcli\windows\Nuget.Config) + $newSource = $xml.CreateElement("add"); + $keyAttr = $xml.CreateAttribute("key"); + $keyAttr.Value ="PrPublish"; + $valueAttr = $xml.CreateAttribute("value"); + $valueAttr.Value ="$(Agent.BuildDirectory)\testcli\localNugets"; + $newSource.Attributes.Append($keyAttr); + $newSource.Attributes.Append($valueAttr); + $packageSources = $xml.ChildNodes.Item(1).packageSources; + $packageSources.InsertBefore($newSource, $packageSources.FirstChild); + $xml.save("$(Agent.BuildDirectory)\testcli\windows\Nuget.Config"); + + condition: and(succeeded(), eq('true', ${{ parameters.experimentalNugetDependency }})) - template: install-SDK.yml parameters: @@ -114,31 +120,23 @@ steps: -Cleanup:$true condition: and(succeeded(), ${{ parameters.installVsComponents }}) - - task: VSBuild@1 - displayName: VSBuild - testcli + # Work around issue of parameters not getting expanded in conditions properly + - powershell: | + Write-Host "##vso[task.setvariable variable=localConfig]${{ parameters.configuration}}" + + - task: CmdLine@2 + displayName: Build project (Release) inputs: - solution: $(Agent.BuildDirectory)\testcli\windows\testcli.sln - 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 - msbuildArgs: - /p:PreferredToolArchitecture=$(MSBuildPreferredToolArchitecture) - /p:PlatformToolset=$(MSBuildPlatformToolset) - /p:AppxGeneratePrisForPortableLibrariesEnabled=false - - - task: PublishBuildArtifacts@1 - condition: succeededOrFailed() - timeoutInMinutes: 10 + script: npx --no-install react-native run-windows --arch ${{ parameters.platform }} --no-launch --no-deploy --logging --release + workingDirectory: $(Agent.BuildDirectory)\testcli + condition: and(succeeded(), eq('Release', variables['localConfig'])) + + - task: CmdLine@2 + displayName: Build project (Debug) inputs: - pathtoPublish: $(Agent.BuildDirectory)/testcli/windows/testcli.sln.log - artifactName: Detailed Logs for testcli.sln ${{ parameters.platform }} ${{ parameters.configuration }} ${{ parameters.experimentalNugetDependency }} - publishLocation: 'Container' + script: npx --no-install react-native run-windows --arch ${{ parameters.platform }} --no-launch --no-deploy --logging + workingDirectory: $(Agent.BuildDirectory)\testcli + condition: and(succeeded(), eq('Debug', variables['localConfig'])) - task: CmdLine@2 displayName: Create bundle testcli diff --git a/change/react-native-windows-2020-04-14-15-18-42-moreclitest.json b/change/react-native-windows-2020-04-14-15-18-42-moreclitest.json new file mode 100644 index 00000000000..e4654656a61 --- /dev/null +++ b/change/react-native-windows-2020-04-14-15-18-42-moreclitest.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "Add msbuild.ProjectImports.zip to default blacklist to avoid metro error on run-windows", + "packageName": "react-native-windows", + "email": "acoates@microsoft.com", + "dependentChangeType": "patch", + "date": "2020-04-14T22:18:42.005Z" +} \ 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 c59293bd56a..13b2e476bf0 100644 --- a/vnext/local-cli/generator-windows/index.js +++ b/vnext/local-cli/generator-windows/index.js @@ -118,7 +118,7 @@ function copyProjectTemplateAndReplace( // Once we are publishing to nuget.org, this shouldn't be needed anymore if (options.experimentalNugetDependency) { [ - { from: path.join(srcPath, projDir, 'NuGet.Config'), to: 'NuGet.Config' }, + { from: path.join(srcPath, projDir, 'NuGet.Config'), to: path.join(windowsDir, 'NuGet.Config') }, ].forEach((mapping) => copyAndReplaceWithChangedCallback(mapping.from, destPath, mapping.to, templateVars, options.overwrite)); } } diff --git a/vnext/local-cli/generator-windows/templates/metro.config.js b/vnext/local-cli/generator-windows/templates/metro.config.js index 0cf35e4acf6..d3d86824f7b 100644 --- a/vnext/local-cli/generator-windows/templates/metro.config.js +++ b/vnext/local-cli/generator-windows/templates/metro.config.js @@ -17,6 +17,12 @@ module.exports = { new RegExp( `${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`, ), + // This prevents "react-native run-windows" from hitting: EBUSY: resource busy or locked, open msbuild.ProjectImports.zip + new RegExp( + `${path + .resolve(__dirname, 'msbuild.ProjectImports.zip') + .replace(/[/\\]/g, '/')}.*`, + ), ]), }, transformer: { diff --git a/vnext/local-cli/runWindows/utils/build.js b/vnext/local-cli/runWindows/utils/build.js index 620bd2aaaa5..fbec47fe0fd 100644 --- a/vnext/local-cli/runWindows/utils/build.js +++ b/vnext/local-cli/runWindows/utils/build.js @@ -9,6 +9,7 @@ const fs = require('fs'); const os = require('os'); const path = require('path'); +const {execSync} = require('child_process'); const glob = require('glob'); const MSBuildTools = require('./msbuildtools'); const Version = require('./version'); @@ -63,16 +64,22 @@ async function nugetRestore(nugetPath, slnFile, verbose, msbuildVersion) { } async function restoreNuGetPackages(options, slnFile, verbose) { - const nugetPath = + let nugetPath = options.nugetPath || path.join(os.tmpdir(), 'nuget.4.9.2.exe'); - const dlNugetText = 'Downloading NuGet Binary'; - const ensureNugetSpinner = newSpinner(dlNugetText); - const exists = await existsAsync(nugetPath); - if (!exists) { + const ensureNugetSpinner = newSpinner('Locating NuGet executable'); + if (!(await existsAsync(nugetPath))) { + try { + nugetPath = execSync('where nuget') + .toString() + .trim(); + } catch {} + } + + if (!(await existsAsync(nugetPath))) { await commandWithProgress( ensureNugetSpinner, - dlNugetText, + 'Downloading NuGet Binary', 'powershell', `$progressPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue; Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/v4.9.2/nuget.exe -outfile ${nugetPath}`.split( ' ', @@ -82,6 +89,10 @@ async function restoreNuGetPackages(options, slnFile, verbose) { } ensureNugetSpinner.succeed('Found NuGet Binary'); + if (verbose) { + console.log(`Using Nuget: ${nugetPath}`); + } + const msbuildTools = MSBuildTools.findAvailableVersion('x86', verbose); try { await nugetRestore(