----------
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
---------
:: 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
REM ===
REM =========================================================================================
call %__ThisScriptPath%init-tools.cmd
+if errorlevel 1 (
+ echo ERROR: Could not restore build tools.
+ exit /b 1
+)
REM =========================================================================================
REM ===
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
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] (
:: 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%"
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
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
:: 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%