Skip to content

Commit 470d30d

Browse files
author
Dimitar Kerezov
committed
WIP
1 parent 4709434 commit 470d30d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

setup/native-script.ps1

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11

22
# A PowerShell script to set up Windows machine for NativeScript development
33
# NOTE: The scripts requires at least a version 4.0 .NET framework installed
4-
# To run it inside a COMMAND PROMPT against the production branch (only one supported with self-elevation) use
5-
# @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"
6-
# To run it inside a WINDOWS POWERSHELL console against the production branch (only one supported with self-elevation) use
7-
# start-process -FilePath PowerShell.exe -NoNewWindow -Wait -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"
4+
# To run it inside a COMMAND PROMPT against the kerezov/setup-scripts branch (only one supported with self-elevation) use
5+
# @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/kerezov/setup-scripts/setup/native-script.ps1'))"
6+
# To run it inside a WINDOWS POWERSHELL console against the kerezov/setup-scripts branch (only one supported with self-elevation) use
7+
# iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/kerezov/setup-scripts/setup/native-script.ps1'))
88

99
# Check if latest .NET framework installed is at least 4
1010
$dotNetVersions = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | Get-ItemProperty -name Version,Release -EA 0 | Where { $_.PSChildName -match '^(?!S)\p{L}'} | Select Version
1111
$latestDotNetVersion = $dotNetVersions.GetEnumerator() | Sort-Object Version | Select-Object -Last 1
1212
$latestDotNetMajorNumber = $latestDotNetVersion.Version.Split(".")[0]
1313
if ($latestDotNetMajorNumber -lt 4) {
14-
Write-Host -BackgroundColor Black -ForegroundColor Red "Running this script requires at least a version 4.0 .NET framework installed"
14+
Write-Host -ForegroundColor Red "Running this script requires at least a version 4.0 .NET framework installed"
1515
if ((Read-Host "Do you want to open Microsoft's Download Center in your default browser(y/n)") -eq 'y') {
1616
Start-Process -FilePath "https://www.microsoft.com/en-us/download/search.aspx?q=.net%20framework&p=0&r=10&t=&s=Relevancy~Descending"
1717
}
@@ -22,30 +22,30 @@ if ($latestDotNetMajorNumber -lt 4) {
2222
# Self-elevate
2323
$isElevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")
2424
if (-not $isElevated) {
25-
start-process -FilePath PowerShell.exe -Verb Runas -Wait -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"
25+
start-process -FilePath PowerShell.exe -Verb Runas -Wait -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/kerezov/setup-scripts/setup/native-script.ps1'))"
2626
exit 0
2727
}
2828

2929
# Help with installing other dependencies
3030
$script:answer = ""
3131
function Install($programName, $message, $script, $shouldExit) {
3232
if ($script:answer -ne "all") {
33-
Write-Host -BackgroundColor Black -ForegroundColor Green "Allow the script to install $($programName)?"
34-
Write-Host -BackgroundColor Black "Tip: Note that if you type all you won't be prompted for subsequent installations"
33+
Write-Host -ForegroundColor Green "Allow the script to install $($programName)?"
34+
Write-Host "Tip: Note that if you type all you won't be prompted for subsequent installations"
3535
do {
3636
$script:answer = (Read-Host "y/n/all").ToLower()
3737
} until ($script:answer -eq "y" -or $script:answer -eq "n" -or $script:answer -eq "all")
3838

3939
if ($script:answer -eq "n") {
40-
Write-Host -BackgroundColor Black -ForegroundColor Yellow "You've chosen not to install $($programName) some features of NativeScript may not work correctly if you haven't already installed it"
40+
Write-Host -ForegroundColor Yellow "You've chosen not to install $($programName) some features of NativeScript may not work correctly if you haven't already installed it"
4141
return
4242
}
4343
}
4444

45-
Write-Host -BackgroundColor Black $message
45+
Write-Host $message
4646
Invoke-Expression($script)
4747
if ($LASTEXITCODE -ne 0) {
48-
Write-Host -BackgroundColor Black -ForegroundColor Yellow "WARNING: $($programName) not installed"
48+
Write-Host -ForegroundColor Yellow "WARNING: $($programName) not installed"
4949
}
5050
}
5151

@@ -59,7 +59,7 @@ function Pause {
5959
Install "Chocolately(It's mandatory for the rest of the script)" "Installing Chocolately" "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"
6060

6161
if ((Get-Command "cinst" -ErrorAction SilentlyContinue) -eq $null) {
62-
Write-Host -BackgroundColor Black -ForegroundColor Red "Chocolatey is not installed or not configured properly. Download it from https://chocolatey.org/, install, set it up and run this script again."
62+
Write-Host -ForegroundColor Red "Chocolatey is not installed or not configured properly. Download it from https://chocolatey.org/, install, set it up and run this script again."
6363
Pause
6464
exit 1
6565
}
@@ -90,5 +90,5 @@ if (!$env:JAVA_HOME) {
9090
$env:JAVA_HOME = $javaHome;
9191
}
9292

93-
Write-Host -BackgroundColor Black -ForegroundColor Green "This script has modified your environment. You need to log off and log back on for the changes to take effect."
93+
Write-Host -ForegroundColor Green "This script has modified your environment. You need to log off and log back on for the changes to take effect."
9494
Pause

0 commit comments

Comments
 (0)