11
2- # A Boxstarter script to set up Windows machine for NativeScript development
3- # To run it against RELEASE branch (recommended) use
4- # http://boxstarter.org/package/nr/url?https://raw.githubusercontent.com/NativeScript/nativescript-cli/release/setup/native-script.ps1
5- # To run it against MASTER branch (usually only developers of NativeScript need to) use
6- # http://boxstarter.org/package/nr/url?https://raw.githubusercontent.com/NativeScript/nativescript-cli/master/setup/native-script.ps1
2+ # A PowerShell script to set up Windows machine for NativeScript development
3+ # To run it against the PRODUCTION branch (only one supported with self-elevation) use
4+ # @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"
5+
6+ # Self-elevate
7+ $isElevated = ([Security.Principal.WindowsPrincipal ] [Security.Principal.WindowsIdentity ]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole ]" Administrator" )
8+ if (-not $isElevated ) {
9+ start-process - FilePath PowerShell.exe - NoProfile - ExecutionPolicy Bypass - Verb Runas - Wait - Command " iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"
10+ exit 0
11+ }
12+
13+ # Install Chocolately
14+ iex ((new-object net.webclient).DownloadString(' https://chocolatey.org/install.ps1' ))
715
816# install dependenciess with Chocolately
917
18+ write-host " To ensure consistent environment, this script will re-install all NativeScript dependencies."
19+
1020write-host - BackgroundColor Black - ForegroundColor Yellow " Installing Google Chrome (required to debug NativeScript apps)"
11- cinst googlechrome
21+ cinst googlechrome -- force -- yes
1222
1323write-host - BackgroundColor Black - ForegroundColor Yellow " Installing node.js"
14- cinst nodejs.install - version 4.2 . 5
24+ cinst nodejs.install - version 4.3 . 0 -- force -- yes
1525
1626write-host - BackgroundColor Black - ForegroundColor Yellow " Installing Java Development Kit"
17- cinst jdk8
27+ cinst jdk8 -- force -- yes
1828
1929write-host - BackgroundColor Black - ForegroundColor Yellow " Installing Android SDK"
20- cinst android- sdk
30+ cinst android- sdk -- force -- yes
2131
2232# setup android sdk
2333echo yes | cmd / c " $env: localappdata \Android\android-sdk\tools\android" update sdk -- filter " tools,platform-tools,android-23" -- all -- no- ui
@@ -27,12 +37,14 @@ echo yes | cmd /c "$env:localappdata\Android\android-sdk\tools\android" update s
2737
2838if (! $env: ANDROID_HOME ) {
2939 [Environment ]::SetEnvironmentVariable(" ANDROID_HOME" , " $env: localappdata \Android\android-sdk" , " User" )
40+ $env: ANDROID_HOME = " $env: localappdata \Android\android-sdk" ;
3041}
3142
3243if (! $env: JAVA_HOME ) {
3344 $curVer = (Get-ItemProperty " HKLM:\SOFTWARE\JavaSoft\Java Development Kit" ).CurrentVersion
3445 $javaHome = (Get-ItemProperty " HKLM:\Software\JavaSoft\Java Development Kit\$curVer " ).JavaHome
3546 [Environment ]::SetEnvironmentVariable(" JAVA_HOME" , $javaHome , " User" )
47+ $env: JAVA_HOME = $javaHome ;
3648}
3749
3850# install NativeScript CLI
@@ -43,6 +55,8 @@ $pathMachine = [Environment]::GetEnvironmentVariable("PATH", "Machine")
4355$myPath = [Environment ]::GetEnvironmentVariable(" PATH" )
4456[Environment ]::SetEnvironmentVariable(" PATH" , " $myPath ;$oldPathUser ;$pathMachine ;$env: ProgramFiles \nodejs" )
4557
46- cmd / c " npm" install - g nativescript
58+ npm install - g nativescript
4759
4860write-host - BackgroundColor Black - ForegroundColor Yellow " This script has modified your environment. You need to log off and log back on for the changes to take effect."
61+ Write-Host " Press any key to continue..."
62+ [void ][System.Console ]::ReadKey($true )
0 commit comments