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
7 changes: 7 additions & 0 deletions .ado/windows-vs-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ jobs:
clean: false
submodules: false

- task: PowerShell@2
displayName: "Check if this environment meets the development dependencies"
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)\vnext\Scripts\rnw-dependencies.ps1
arguments: -NoPrompt

- template: templates/build-rnw.yml
parameters:
yarnBuildCmd: build
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "add rnw-dependencies.ps1",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch",
"date": "2020-05-12T00:22:16.000Z"
}
4 changes: 2 additions & 2 deletions docs/building-rnw.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Note that react-native-windows is a monorepo and relies on monorepo tools like y
There are two ways to run the app. In a fully managed easy way, or by manually running all the required steps:

## Automatic
The playground app can be run in a completely automatic way by using `react-native run-windows`.
The playground app can be run in a completely automatic way by using `react-native run-windows --sln windows\playground.sln`.

If you haven't already, install the react-native-cli (One time only!)
```cmd
Expand All @@ -33,7 +33,7 @@ Then

```cmd
cd packages\playground
react-native run-windows
react-native run-windows --sln windows\playground.sln
```

## Manual
Expand Down
147 changes: 147 additions & 0 deletions vnext/Scripts/rnw-dependencies.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Troubleshoot RNW dependencies
param([switch]$Install = $false, [switch]$NoPrompt = $false)
$vsWorkloads = @( 'Microsoft.Component.MSBuild', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64', 'Microsoft.VisualStudio.ComponentGroup.UWP.Support');

$v = [System.Environment]::OSVersion.Version;
if ($env:Agent_BuildDirectory) {
$drive = (Resolve-Path $env:Agent_BuildDirectory).Drive
} else {
$drive = (Resolve-Path $PSCommandPath).Drive
}

function CheckVS {
$vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if (!(Test-Path $vsWhere)) {
return $false;
}
$output = & $vsWhere -version 16 -requires $vsWorkloads -property productPath
return Test-Path $output;
}

function InstallVS {
$installerPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer";
$vsWhere = "$installerPath\vswhere.exe"
if (!(Test-Path $vsWhere)) {
# No VSWhere / VS_Installer
& choco install -y visualstudio2019community
}
$channelId = & $vsWhere -version 16 -property channelId
$productId = & $vsWhere -version 16 -property productId
$vsInstaller = "$installerPath\vs_installer.exe"
$addWorkloads = $vsWorkloads | % { '--add', $_ };
Start-Process -PassThru -Wait -Path $vsInstaller -ArgumentList ("install --channelId $channelId --productId $productId $addWorkloads --quiet" -split ' ')

}

function CheckNode {
try {
$v = (Get-Command node).Version.Major
return $v -eq 12 -or $v -eq 13
} catch {
return $false;
}
}

function GetChocoPkgVersion{
params([string]$packageId)
[version]$version = (& choco list --local-only $packageId -r -e).Substring($packageId.Length + 1);
return $version;
}

$requiredFreeSpaceGB = 15;

$requirements = @(
@{
Name = "Free space on $drive`: > $requiredFreeSpaceGB GB";
Valid = $drive.Free/1GB -gt $requiredFreeSpaceGB;
Optional = $true # this requirement is fuzzy
},
@{
Name = 'Windows version > 10.0.16299.0';
Valid = ($v.Major -eq 10 -and $v.Minor -eq 0 -and $v.Build -ge 16299)
},
@{
Name = 'Developer mode is on';
Valid = try { (Get-WindowsDeveloperLicense).IsValid } catch { $false }
},
@{
Name = 'git';
Valid = try { (Get-Command git.exe) -ne $null } catch { $false }
}
@{
Name = 'Choco';
Valid = try { (Get-Command choco) -ne $null } catch { $false };
Install = {
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
};
},
@{
Name = 'VS 2019 with UWP and Desktop/C++';
Valid = CheckVS
},
@{
Name = 'NodeJS 12 or 13 installed';
Valid = CheckNode
Install = { choco install -y nodejs.install --version=12.9.1 }
},
@{
Name = 'Chrome';
Valid = try { ((Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe').'(Default)').VersionInfo).ProductMajorPart
} catch { $false } ;
Install = { choco install -y GoogleChrome }
},
@{
Name = 'Yarn';
Valid = try { (Get-Command yarn) -ne $null } catch { $false };
Install = { choco install -y yarn }
},
@{
Name = 'Appium';
Valid = (Test-Path "${env:ProgramFiles}\Appium\Appium.exe");
Install = { choco install -y Appium-desktop };
Optional = $true
},
@{
Name = 'WinAppDriver';
Valid = (Test-Path "${env:ProgramFiles(x86)}\Windows Application Driver\WinAppDriver.exe");
Install = { choco install -y WinAppDriver };
}

);

function IsElevated {
return [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544");
}

if (!(IsElevated)) {
Write-Output "rnw-dependencies - this script must run elevated. Exiting.";
return;
}

$NeedsRerun = $false
foreach ($req in $requirements)
{
Write-Output "Checking $($req.Name)";
if (!($req.Valid)) {
Write-Output "Requirement failed: $($req.Name)";
if ($req.Install) {
if ($Install -or (!$NoPrompt -and (Read-Host "Do you want to install? ").ToUpperInvariant() -eq 'Y')) {
Invoke-Command $req.Install -ErrorAction Stop
if ($LASTEXITCODE -ne 0) { throw "Last exit code was non-zero: $LASTEXITCODE"; }
} elseif (!$req.Optional) {
$NeedsRerun = $true;
}
} else {
$NeedsRerun = !($req.Optional);
}
}
}

if ($NeedsRerun) {
Write-Output "Some dependencies are not met. Re-run with -Install to install them.";
exit 1;
} else {
Write-Output "All mandatory requirements met";
exit 0;
}