summaryrefslogtreecommitdiff
path: root/build.cmd
diff options
context:
space:
mode:
authorAndy Ayers <andya@microsoft.com>2016-04-15 14:03:46 -0700
committerAndy Ayers <andya@microsoft.com>2016-04-15 17:58:57 -0700
commitc5be17651cdbe0c60833b2953bae828acb1a0e60 (patch)
tree129d504d378a961a6aaf781cea91ddf0b3279e47 /build.cmd
parent02d18c9eceeb3c4e80c5c59dbc8103294adc86af (diff)
downloadcoreclr-c5be17651cdbe0c60833b2953bae828acb1a0e60.tar.gz
coreclr-c5be17651cdbe0c60833b2953bae828acb1a0e60.tar.bz2
coreclr-c5be17651cdbe0c60833b2953bae828acb1a0e60.zip
Detect if powershell version is suitable for restoring build tools
Powershell v3 or higher is required to decompress the build tools bundle. Windows 7 typically has v2 installed. Detect earlier versions and fail with a pointer to the build prerequisites and a download link for an updated version. Also propagate failures out of init-tools.cmd. The last step of this is unchecked since the build tool init script can return nonzero status even on success. See #3510.
Diffstat (limited to 'build.cmd')
-rw-r--r--build.cmd24
1 files changed, 21 insertions, 3 deletions
diff --git a/build.cmd b/build.cmd
index 6461ff3e46..aa1201bd01 100644
--- a/build.cmd
+++ b/build.cmd
@@ -217,7 +217,15 @@ echo %__MsgPrefix%Checking prerequisites
:: Validate that PowerShell is accessibile.
for %%X in (powershell.exe) do (set __PSDir=%%~$PATH:X)
-if not defined __PSDir goto NoPS
+if not defined __PSDir goto :NoPS
+
+:: Validate Powershell version
+set PS_VERSION_LOG=%~dp0ps-version.log
+powershell -NoProfile -ExecutionPolicy unrestricted -Command "$PSVersionTable.PSVersion.Major" > %PS_VERSION_LOG%
+set /P PS_VERSION=< %PS_VERSION_LOG%
+if %PS_VERSION% LEQ 2 (
+ goto :OldPS
+)
:: Eval the output from probe-win1.ps1
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy RemoteSigned "& ""%__SourceDir%\pal\tools\probe-win.ps1"""') do %%a
@@ -260,6 +268,10 @@ REM === Restore Build Tools
REM ===
REM =========================================================================================
call %__ThisScriptPath%init-tools.cmd
+if errorlevel 1 (
+ echo ERROR: Could not restore build tools.
+ exit /b 1
+)
REM =========================================================================================
REM ===
@@ -655,14 +667,20 @@ echo -- builds x64 and x86 architectures, Checked and Release build types
exit /b 1
:NoPS
-echo PowerShell is a prerequisite to build this repository, but it is not accessible.
+echo PowerShell v3.0 or later is a prerequisite to build this repository, but it is not accessible.
echo Ensure that it is defined in the PATH environment variable.
echo Typically it should be %%SYSTEMROOT%%\System32\WindowsPowerShell\v1.0\.
exit /b 1
+:OldPS
+echo PowerShell v3.0 or later is a prerequisite to build this repository.
+echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-instructions.md
+echo Download via https://www.microsoft.com/en-us/download/details.aspx?id=40855
+exit /b 1
+
:NoVS
echo Visual Studio 2015+ ^(Community is free^) is a prerequisite to build this repository.
-echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
+echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-instructions.md
exit /b 1
:NoDIA