Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
62 changes: 30 additions & 32 deletions .ado/templates/react-native-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion vnext/local-cli/generator-windows/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
6 changes: 6 additions & 0 deletions vnext/local-cli/generator-windows/templates/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How hard do you think it would be to generally avoid putting build files in a place where metro will try to read them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what controls the location of msbuild.ProjectImports.zip. If someone does, then I would agree.

`${path
.resolve(__dirname, 'msbuild.ProjectImports.zip')
.replace(/[/\\]/g, '/')}.*`,
),
]),
},
transformer: {
Expand Down
23 changes: 17 additions & 6 deletions vnext/local-cli/runWindows/utils/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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(
' ',
Expand All @@ -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(
Expand Down