Skip to content

Commit 85a3f2d

Browse files
Merge pull request #1459 from NativeScript/totev/setup-v2
More setup fixes for Windows
2 parents db9d002 + c1ca274 commit 85a3f2d

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

setup/native-script.ps1

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
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+
1020
write-host -BackgroundColor Black -ForegroundColor Yellow "Installing Google Chrome (required to debug NativeScript apps)"
11-
cinst googlechrome
21+
cinst googlechrome --force --yes
1222

1323
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
1525

1626
write-host -BackgroundColor Black -ForegroundColor Yellow "Installing Java Development Kit"
17-
cinst jdk8
27+
cinst jdk8 --force --yes
1828

1929
write-host -BackgroundColor Black -ForegroundColor Yellow "Installing Android SDK"
20-
cinst android-sdk
30+
cinst android-sdk --force --yes
2131

2232
# setup android sdk
2333
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
2737

2838
if (!$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

3243
if (!$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

4860
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

Comments
 (0)