1
1
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' ))
7
15
8
16
# install dependenciess with Chocolately
9
17
18
+ write-host " To ensure consistent environment, this script will re-install all NativeScript dependencies."
19
+
10
20
write-host - BackgroundColor Black - ForegroundColor Yellow " Installing Google Chrome (required to debug NativeScript apps)"
11
- cinst googlechrome
21
+ cinst googlechrome -- force -- yes
12
22
13
23
write-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
15
25
16
26
write-host - BackgroundColor Black - ForegroundColor Yellow " Installing Java Development Kit"
17
- cinst jdk8
27
+ cinst jdk8 -- force -- yes
18
28
19
29
write-host - BackgroundColor Black - ForegroundColor Yellow " Installing Android SDK"
20
- cinst android- sdk
30
+ cinst android- sdk -- force -- yes
21
31
22
32
# setup android sdk
23
33
echo 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
27
37
28
38
if (! $env: ANDROID_HOME ) {
29
39
[Environment ]::SetEnvironmentVariable(" ANDROID_HOME" , " $env: localappdata \Android\android-sdk" , " User" )
40
+ $env: ANDROID_HOME = " $env: localappdata \Android\android-sdk" ;
30
41
}
31
42
32
43
if (! $env: JAVA_HOME ) {
33
44
$curVer = (Get-ItemProperty " HKLM:\SOFTWARE\JavaSoft\Java Development Kit" ).CurrentVersion
34
45
$javaHome = (Get-ItemProperty " HKLM:\Software\JavaSoft\Java Development Kit\$curVer " ).JavaHome
35
46
[Environment ]::SetEnvironmentVariable(" JAVA_HOME" , $javaHome , " User" )
47
+ $env: JAVA_HOME = $javaHome ;
36
48
}
37
49
38
50
# install NativeScript CLI
@@ -43,6 +55,8 @@ $pathMachine = [Environment]::GetEnvironmentVariable("PATH", "Machine")
43
55
$myPath = [Environment ]::GetEnvironmentVariable(" PATH" )
44
56
[Environment ]::SetEnvironmentVariable(" PATH" , " $myPath ;$oldPathUser ;$pathMachine ;$env: ProgramFiles \nodejs" )
45
57
46
- cmd / c " npm" install - g nativescript
58
+ npm install - g nativescript
47
59
48
60
write-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