diff options
author | Andy Ayers <andya@microsoft.com> | 2016-04-18 23:21:02 -0700 |
---|---|---|
committer | Andy Ayers <andya@microsoft.com> | 2016-04-18 23:21:02 -0700 |
commit | fa9d085cfffe748f0bb9c977d0ddf00b0d654168 (patch) | |
tree | 2e4e76527df7f48054e12e866b70306d8ca69236 | |
parent | 87ce0d9914c5f4dc8c2c0e3b8ce4dba7e2b2f1ab (diff) | |
parent | c5be17651cdbe0c60833b2953bae828acb1a0e60 (diff) | |
download | coreclr-fa9d085cfffe748f0bb9c977d0ddf00b0d654168.tar.gz coreclr-fa9d085cfffe748f0bb9c977d0ddf00b0d654168.tar.bz2 coreclr-fa9d085cfffe748f0bb9c977d0ddf00b0d654168.zip |
Merge pull request #4374 from AndyAyersMS/CheckToolRestore
Detect if powershell version is suitable for restoring build tools
-rw-r--r-- | Documentation/building/windows-instructions.md | 3 | ||||
-rw-r--r-- | build.cmd | 24 | ||||
-rw-r--r-- | init-tools.cmd | 15 |
3 files changed, 35 insertions, 7 deletions
diff --git a/Documentation/building/windows-instructions.md b/Documentation/building/windows-instructions.md index 6ac3933312..ac85d0c319 100644 --- a/Documentation/building/windows-instructions.md +++ b/Documentation/building/windows-instructions.md @@ -36,6 +36,9 @@ PowerShell ---------- PowerShell is used in the build system. Ensure that it is accessible via the PATH environment variable. Typically this is %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\. +Powershell version must be 3.0 or higher. This should be the case for Windows 8 and later builds. +- Windows 7 SP1 can install Powershell version 4 [here](https://www.microsoft.com/en-us/download/details.aspx?id=40855). + Git Setup --------- @@ -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 diff --git a/init-tools.cmd b/init-tools.cmd index 387ede7a1d..f95f56e57e 100644 --- a/init-tools.cmd +++ b/init-tools.cmd @@ -13,6 +13,7 @@ set PROJECT_JSON_PATH=%TOOLRUNTIME_DIR%\%BUILDTOOLS_VERSION% set PROJECT_JSON_FILE=%PROJECT_JSON_PATH%\project.json set PROJECT_JSON_CONTENTS={ "dependencies": { "Microsoft.DotNet.BuildTools": "%BUILDTOOLS_VERSION%" , "Microsoft.DotNet.BuildTools.Coreclr": "1.0.4-prerelease"}, "frameworks": { "dnxcore50": { } } } set BUILD_TOOLS_SEMAPHORE=%PROJECT_JSON_PATH%\init-tools.completed +set TOOLS_INIT_RETURN_CODE=0 :: if force option is specified then clean the tool runtime and build tools package directory to force it to get recreated if [%1]==[force] ( @@ -23,7 +24,7 @@ if [%1]==[force] ( :: If sempahore exists do nothing if exist "%BUILD_TOOLS_SEMAPHORE%" ( echo Tools are already initialized. - goto :EOF + goto :DONE ) if exist "%TOOLRUNTIME_DIR%" rmdir /S /Q "%TOOLRUNTIME_DIR%" @@ -50,7 +51,8 @@ echo Installing '%DOTNET_REMOTE_PATH%' to '%DOTNET_LOCAL_PATH%' >> %INIT_TOOLS_L powershell -NoProfile -ExecutionPolicy unrestricted -Command "(New-Object Net.WebClient).DownloadFile('%DOTNET_REMOTE_PATH%', '%DOTNET_LOCAL_PATH%'); Add-Type -Assembly 'System.IO.Compression.FileSystem' -ErrorVariable AddTypeErrors; if ($AddTypeErrors.Count -eq 0) { [System.IO.Compression.ZipFile]::ExtractToDirectory('%DOTNET_LOCAL_PATH%', '%DOTNET_PATH%') } else { (New-Object -com shell.application).namespace('%DOTNET_PATH%').CopyHere((new-object -com shell.application).namespace('%DOTNET_LOCAL_PATH%').Items(),16) }" >> %INIT_TOOLS_LOG% if NOT exist "%DOTNET_LOCAL_PATH%" ( echo ERROR: Could not install dotnet cli correctly. See '%INIT_TOOLS_LOG%' for more details. - goto :EOF + set TOOLS_INIT_RETURN_CODE=1 + goto :DONE ) :afterdotnetrestore @@ -61,7 +63,8 @@ echo Running: "%DOTNET_CMD%" restore "%PROJECT_JSON_FILE%" --packages %PACKAGES_ call "%DOTNET_CMD%" restore "%PROJECT_JSON_FILE%" --packages %PACKAGES_DIR% --source "%BUILDTOOLS_SOURCE%" >> %INIT_TOOLS_LOG% if NOT exist "%BUILD_TOOLS_PATH%init-tools.cmd" ( echo ERROR: Could not restore build tools correctly. See '%INIT_TOOLS_LOG%' for more details. - goto :EOF + set TOOLS_INIT_RETURN_CODE=1 + goto :DONE ) :afterbuildtoolsrestore @@ -72,4 +75,8 @@ call "%BUILD_TOOLS_PATH%init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR :: Create sempahore file echo Done initializing tools. -echo Init-Tools.cmd completed for BuildTools Version: %BUILDTOOLS_VERSION% > "%BUILD_TOOLS_SEMAPHORE%"
\ No newline at end of file +echo Init-Tools.cmd completed for BuildTools Version: %BUILDTOOLS_VERSION% > "%BUILD_TOOLS_SEMAPHORE%" + +:DONE + +exit /b %TOOLS_INIT_RETURN_CODE% |