Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
7 changes: 4 additions & 3 deletions .ado/VSComponentList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ Invoke-WebRequest -Uri 'https://download.visualstudio.microsoft.com/download/pr/
$p = Start-Process -PassThru $dir\vs_enterprise.exe -RedirectStandardError $dir\err -RedirectStandardOutput $dir\out -ArgumentList "export --installpath `"$installationPath`" --quiet --config $vsconfig"
$p.WaitForExit()
$x = [Datetime]::Now.AddSeconds(60)
while (!(Test-Path $vsconfig) -and ([datetime]::Now -lt $x))

do
{
Sleep 5
Write-Host "Waiting for vsconfig file..."
}
Sleep 5
} while (!(Test-Path $vsconfig) -and ([datetime]::Now -lt $x))

Get-Content $dir\err
Get-Content $dir\out
Expand Down
1 change: 0 additions & 1 deletion .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ jobs:
- template: templates/build-rnw.yml
parameters:
project: vnext/ReactWindows-Universal.sln
vsComponents: $(VsComponents)

- template: templates/publish-build-artifacts-for-nuget.yml
parameters:
Expand Down
6 changes: 4 additions & 2 deletions .ado/templates/build-rnw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ parameters:
yarnBuildCmd: build

# Visual Studio Installer
vsInstallerUri: $(VsInstallerUri)
vsComponents: ''
listVsComponents: false
installVsComponents: false

steps:
- template: prepare-env.yml
parameters:
vsInstallerUri: ${{ parameters.vsInstallerUri }}
vsComponents: ${{ parameters.vsComponents }}
listVsComponents: ${{ parameters.listVsComponents }}
installVsComponents: ${{ parameters.installVsComponents }}
yarnBuildCmd: ${{ parameters.yarnBuildCmd }}
debug: ${{ parameters.debug }}

Expand Down
3 changes: 0 additions & 3 deletions .ado/templates/e2e-test-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ jobs:
Get-WmiObject Win32_LogicalDisk

- template: prepare-env.yml
parameters:
vsComponents: $(VsComponents)
yarnBuildCmd: build

- task: NuGetCommand@2
displayName: NuGet restore - ReactUWPTestApp
Expand Down
14 changes: 11 additions & 3 deletions .ado/templates/prepare-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ parameters:
debug: false

# Visual Studio Installer
vsInstallerUri: $(VsInstallerUri)
vsComponents: ''
listVsComponents: false
installVsComponents: false

steps:
- task: PowerShell@2
Expand Down Expand Up @@ -45,16 +46,23 @@ steps:
parameters:
sdkVersion: $(Win10Version)

- task: PowerShell@2
displayName: List Visual Studio Components
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)/.ado/VSComponentList.ps1
condition: and(succeeded(), ${{ parameters.listVsComponents }})

- task: PowerShell@2
displayName: Install Visual Studio dependencies
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)/vnext/Scripts/Tfs/Install-VsFeatures.ps1
arguments:
-InstallerUri ${{ parameters.vsInstallerUri }}
-Components ${{ parameters.vsComponents }}
-Collect:$${{ parameters.debug }}
condition: and(ne('${{ parameters.vsComponents }}', ''), eq(variables['VmImage'], 'windows-2019')) # Note that this is evaluated at parsing, so parameters.vsComponents is never empty
-Cleanup:$true
condition: and(succeeded(), ${{ parameters.installVsComponents }})

- task: PowerShell@2
displayName: List disksize after prepare-env
Expand Down
14 changes: 11 additions & 3 deletions .ado/templates/react-native-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ parameters:
configuration:
experimentalNugetDependency: false
vsComponents: ''
vsInstallerUri: $(VsInstallerUri)
listVsComponents: false
installVsComponents: false

steps:
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
Expand Down Expand Up @@ -96,15 +97,22 @@ steps:
parameters:
sdkVersion: $(Win10Version)

- task: PowerShell@2
displayName: List Visual Studio Components
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)/.ado/VSComponentList.ps1
condition: and(succeeded(), ${{ parameters.listVsComponents }})

- task: PowerShell@2
displayName: Install Visual Studio dependencies
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)/vnext/Scripts/Tfs/Install-VsFeatures.ps1
arguments:
-InstallerUri ${{ parameters.vsInstallerUri }}
-Components ${{ parameters.vsComponents }}
condition: and(ne('${{ parameters.vsComponents }}', ''), eq(variables['VmImage'], 'windows-2019')) # Note that this is evaluated at parsing, so parameters.vsComponents is never empty
-Cleanup:$true
condition: and(succeeded(), ${{ parameters.installVsComponents }})

- task: VSBuild@1
displayName: VSBuild - testcli
Expand Down
3 changes: 1 addition & 2 deletions .ado/variables/msbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ variables:
MSBuildPreferredToolArchitecture: x64
MSBuildPlatformToolset: v142
TargetPlatformVersion: 10.0.18362.0
Win10Version: 18362
VsInstallerUri: 'https://download.visualstudio.microsoft.com/download/pr/c4fef23e-cc45-4836-9544-70e213134bc8/1ee5717e9a1e05015756dff77eb27d554a79a6db91f2716d836df368381af9a1/vs_Enterprise.exe'
Win10Version: 18362
1 change: 0 additions & 1 deletion .ado/variables/vs2019.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
variables:
VmImage: windows-2019
VsComponents: 'Microsoft.Component.MSBuild,Microsoft.VisualStudio.ComponentGroup.UWP.VC,Microsoft.VisualStudio.Component.VC.Tools.x86.x64,Microsoft.VisualStudio.Component.VC.Tools.ARM,Microsoft.VisualStudio.Component.VC.Tools.ARM64'
MSBuildVersion: 16.0
GoogleTestAdapterPath: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\ked32bft.vu0'
BaseIntDir: $(Agent.HomeDirectory)\BaseIntDir # redirect to C:
Expand Down
10 changes: 0 additions & 10 deletions .ado/windows-vs-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ jobs:
parameters:
yarnBuildCmd: build
project: vnext/ReactWindows-Universal.sln
vsComponents: $(VsComponents)

- task: VSTest@2
displayName: Run Universal Unit Tests
Expand Down Expand Up @@ -149,9 +148,6 @@ jobs:
submodules: false

- template: templates/prepare-env.yml
parameters:
vsComponents: $(VsComponents)
yarnBuildCmd: build

- task: NuGetCommand@2
displayName: NuGet restore - Playground
Expand Down Expand Up @@ -252,9 +248,6 @@ jobs:
submodules: false

- template: templates/prepare-env.yml
parameters:
vsComponents: $(VsComponents)
yarnBuildCmd: build

- task: NuGetCommand@2
displayName: NuGet restore - SampleApps
Expand Down Expand Up @@ -508,8 +501,6 @@ jobs:
configuration: $(configuration)
platform: $(platform)
version: $(reactNativeVersion)
vsComponents: $(VsComponents)


- job: CliInitExperimental
displayName: Verify react-native init experimental
Expand All @@ -528,7 +519,6 @@ jobs:
configuration: Release
platform: x64
version: $(reactNativeVersion)
vsComponents: $(VsComponents)
experimentalNugetDependency: true

- job: RNWExtraChecks
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Optimizing VS component installer to speed up CI builds",
"packageName": "react-native-windows",
"email": "jthysell@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-04-07T19:18:49.438Z"
}
111 changes: 75 additions & 36 deletions vnext/Scripts/Tfs/Install-VSFeatures.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,92 @@ param (
[Parameter(Mandatory=$true)]
[string[]] $Components,

[Parameter(Mandatory=$true)]
[uri] $InstallerUri,
[uri] $InstallerUri = "https://download.visualstudio.microsoft.com/download/pr/c4fef23e-cc45-4836-9544-70e213134bc8/1ee5717e9a1e05015756dff77eb27d554a79a6db91f2716d836df368381af9a1/vs_Enterprise.exe",

[string] $VsInstaller = "${env:System_DefaultWorkingDirectory}\vs_Enterprise.exe",

[string] $VsInstallOutputDir = "${env:System_DefaultWorkingDirectory}\vs",

[System.IO.FileInfo] $VsInstallPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Enterprise",

[switch] $Collect
)
[System.IO.FileInfo] $VsInstallerPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer",

[switch] $Collect = $false,

Invoke-WebRequest -Method Get `
-Uri $InstallerUri `
-OutFile $VsInstaller
[switch] $Cleanup = $false,

[switch] $UseWebInstaller = $false
)

$Components | ForEach-Object {
$componentList += '--add', $_
}

$VsInstallOutputDir = "${env:System_DefaultWorkingDirectory}\vs"

New-Item -ItemType directory -Path $VsInstallOutputDir

Start-Process `
-FilePath "$VsInstaller" `
-ArgumentList ( `
'--layout', "$VsInstallOutputDir",
'--wait',
'--norestart',
'--quiet' + `
$componentList
) `
-Wait `
-PassThru

Start-Process `
-FilePath "$VsInstallOutputDir\vs_Enterprise.exe" `
-ArgumentList (
'modify',
'--installPath', "`"$VsInstallPath`"" ,
'--wait',
'--quiet',
'--norestart' + `
$componentList
) `
-Wait `
-PassThru `
-OutVariable returnCode
$LocalVsInstaller = "$VsInstallerPath\vs_installershell.exe"

$UseWebInstaller = $UseWebInstaller -or -not (Test-Path -Path "$LocalVsInstaller")

if ($UseWebInstaller) {
Write-Host "Downloading web installer..."

Invoke-WebRequest -Method Get `
-Uri $InstallerUri `
-OutFile $VsInstaller

New-Item -ItemType directory -Path $VsInstallOutputDir

Write-Host "Running web installer to download requested components..."

Start-Process `
-FilePath "$VsInstaller" `
-ArgumentList ( `
'--layout', "$VsInstallOutputDir",
'--wait',
'--norestart',
'--quiet' + `
$componentList
) `
-Wait `
-PassThru

Write-Host "Running downloaded VS installer to add requested components..."

Start-Process `
-FilePath "$VsInstallOutputDir\vs_Enterprise.exe" `
-ArgumentList (
'modify',
'--installPath', "`"$VsInstallPath`"" ,
'--wait',
'--norestart',
'--quiet' + `
$componentList
) `
-Wait `
-PassThru `
-OutVariable returnCode

if ($Cleanup) {
Write-Host "Cleaning up..."

Remove-Item -Path $VsInstaller
Remove-Item -Path $VsInstallOutputDir -Recurse
}

} else {
Write-Host "Running local installer to add requested components..."

Start-Process `
-FilePath "$LocalVsInstaller" `
-ArgumentList (
'modify',
'--installPath', "`"$VsInstallPath`"" ,
'--norestart',
'--quiet' + `
$componentList
) `
-Wait `
-OutVariable returnCode
}

if ($Collect) {
Invoke-WebRequest -Method Get `
Expand Down
Loading