@@ -7,11 +7,11 @@ if [%TOOLRUNTIME_DIR%]==[] set TOOLRUNTIME_DIR=%~dp0Tools
77set DOTNET_PATH = %TOOLRUNTIME_DIR% \dotnetcli\
88if [%DOTNET_CMD% ]== [] set DOTNET_CMD = %DOTNET_PATH% dotnet.exe
99if [%BUILDTOOLS_SOURCE% ]== [] set BUILDTOOLS_SOURCE = https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json
10- set /P BUILDTOOLS_VERSION = < %~dp0 BuildToolsVersion.txt
10+ set /P BUILDTOOLS_VERSION = < " %~dp0 BuildToolsVersion.txt"
1111set BUILD_TOOLS_PATH = %PACKAGES_DIR% Microsoft.DotNet.BuildTools\%BUILDTOOLS_VERSION% \lib\
1212set PROJECT_JSON_PATH = %TOOLRUNTIME_DIR% \%BUILDTOOLS_VERSION%
1313set PROJECT_JSON_FILE = %PROJECT_JSON_PATH% \project.json
14- set PROJECT_JSON_CONTENTS = { " dependencies" : { " Microsoft.DotNet.BuildTools" : " %BUILDTOOLS_VERSION% " }, " frameworks" : { " dnxcore50 " : { } } }
14+ set PROJECT_JSON_CONTENTS = { " dependencies" : { " Microsoft.DotNet.BuildTools" : " %BUILDTOOLS_VERSION% " }, " frameworks" : { " netcoreapp1.0 " : { } } }
1515set BUILD_TOOLS_SEMAPHORE = %PROJECT_JSON_PATH% \init-tools.completed
1616
1717:: if force option is specified then clean the tool runtime and build tools package directory to force it to get recreated
@@ -29,40 +29,45 @@ if exist "%BUILD_TOOLS_SEMAPHORE%" (
2929if exist " %TOOLRUNTIME_DIR% " rmdir /S /Q " %TOOLRUNTIME_DIR% "
3030
3131if NOT exist " %PROJECT_JSON_PATH% " mkdir " %PROJECT_JSON_PATH% "
32- echo %PROJECT_JSON_CONTENTS% > %PROJECT_JSON_FILE%
33- echo Running %0 > %INIT_TOOLS_LOG%
32+ echo %PROJECT_JSON_CONTENTS% > " %PROJECT_JSON_FILE% "
33+ echo Running %0 > " %INIT_TOOLS_LOG% "
3434
3535if exist " %DOTNET_CMD% " goto :afterdotnetrestore
3636
3737echo Installing dotnet cli...
3838if NOT exist " %DOTNET_PATH% " mkdir " %DOTNET_PATH% "
39- set /p DOTNET_VERSION = < %~dp0 DotnetCLIVersion.txt
39+ set /p DOTNET_VERSION = < " %~dp0 DotnetCLIVersion.txt"
4040set DOTNET_ZIP_NAME = dotnet-dev-win-x64.%DOTNET_VERSION% .zip
41- set DOTNET_REMOTE_PATH = https://dotnetcli.blob.core.windows.net/dotnet/beta /Binaries/%DOTNET_VERSION% /%DOTNET_ZIP_NAME%
41+ set DOTNET_REMOTE_PATH = https://dotnetcli.blob.core.windows.net/dotnet/preview /Binaries/%DOTNET_VERSION% /%DOTNET_ZIP_NAME%
4242set DOTNET_LOCAL_PATH = %DOTNET_PATH%%DOTNET_ZIP_NAME%
43- echo Installing '%DOTNET_REMOTE_PATH% ' to '%DOTNET_LOCAL_PATH% ' >> %INIT_TOOLS_LOG%
44- 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%
43+ echo Installing '%DOTNET_REMOTE_PATH% ' to '%DOTNET_LOCAL_PATH% ' >> " %INIT_TOOLS_LOG% "
44+ powershell -NoProfile -ExecutionPolicy unrestricted -Command " $retryCount = 0; $success = $false; do { try { (New-Object Net.WebClient).DownloadFile('%DOTNET_REMOTE_PATH% ', '%DOTNET_LOCAL_PATH% '); $success = $true; } catch { if ($retryCount -ge 6) { throw; } else { $retryCount++; Start-Sleep -Seconds (5 * $retryCount); } } } while ($success -eq $false); 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% "
4545if NOT exist " %DOTNET_LOCAL_PATH% " (
4646 echo ERROR: Could not install dotnet cli correctly. See '%INIT_TOOLS_LOG% ' for more details.
47- goto : EOF
47+ exit /b 1
4848)
4949
5050:afterdotnetrestore
5151
5252if exist " %BUILD_TOOLS_PATH% " goto :afterbuildtoolsrestore
5353echo Restoring BuildTools version %BUILDTOOLS_VERSION% ...
54- echo Running: " %DOTNET_CMD% " restore " %PROJECT_JSON_FILE% " --packages %PACKAGES_DIR% --source " %BUILDTOOLS_SOURCE% " >> %INIT_TOOLS_LOG%
55- call " %DOTNET_CMD% " restore " %PROJECT_JSON_FILE% " --packages %PACKAGES_DIR% --source " %BUILDTOOLS_SOURCE% " >> %INIT_TOOLS_LOG%
54+ echo Running: " %DOTNET_CMD% " restore " %PROJECT_JSON_FILE% " --packages %PACKAGES_DIR% --source " %BUILDTOOLS_SOURCE% " >> " %INIT_TOOLS_LOG% "
55+ call " %DOTNET_CMD% " restore " %PROJECT_JSON_FILE% " --packages %PACKAGES_DIR% --source " %BUILDTOOLS_SOURCE% " >> " %INIT_TOOLS_LOG% "
5656if NOT exist " %BUILD_TOOLS_PATH% init-tools.cmd" (
5757 echo ERROR: Could not restore build tools correctly. See '%INIT_TOOLS_LOG% ' for more details.
58- goto : EOF
58+ exit /b 1
5959)
6060
6161:afterbuildtoolsrestore
6262
6363echo Initializing BuildTools ...
64- echo Running: " %BUILD_TOOLS_PATH% init-tools.cmd" " %~dp0 " " %DOTNET_CMD% " " %TOOLRUNTIME_DIR% " >> %INIT_TOOLS_LOG%
65- call " %BUILD_TOOLS_PATH% init-tools.cmd" " %~dp0 " " %DOTNET_CMD% " " %TOOLRUNTIME_DIR% " >> %INIT_TOOLS_LOG%
64+ echo Running: " %BUILD_TOOLS_PATH% init-tools.cmd" " %~dp0 " " %DOTNET_CMD% " " %TOOLRUNTIME_DIR% " >> " %INIT_TOOLS_LOG% "
65+ call " %BUILD_TOOLS_PATH% init-tools.cmd" " %~dp0 " " %DOTNET_CMD% " " %TOOLRUNTIME_DIR% " >> " %INIT_TOOLS_LOG% "
66+ set INIT_TOOLS_ERRORLEVEL = %ERRORLEVEL%
67+ if not [%INIT_TOOLS_ERRORLEVEL% ]== [0] (
68+ echo ERROR: An error occured when trying to initialize the tools. Please check '%INIT_TOOLS_LOG% ' for more details.
69+ exit /b %INIT_TOOLS_ERRORLEVEL%
70+ )
6671
6772:: Create sempahore file
6873echo Done initializing tools.
0 commit comments