diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
commit | 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch) | |
tree | 98110734c91668dfdbb126fcc0e15ddbd93738ca /init-tools.cmd | |
parent | fa45f57ed55137c75ac870356a1b8f76c84b229c (diff) | |
download | coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2 coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip |
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'init-tools.cmd')
-rw-r--r-- | init-tools.cmd | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/init-tools.cmd b/init-tools.cmd new file mode 100644 index 0000000000..1bdf2a89a5 --- /dev/null +++ b/init-tools.cmd @@ -0,0 +1,82 @@ +@echo off +setlocal + +set INIT_TOOLS_LOG=%~dp0init-tools.log +set PACKAGES_DIR=%~dp0packages\ +set TOOLRUNTIME_DIR=%~dp0Tools +set DOTNET_PATH=%TOOLRUNTIME_DIR%\dotnetcli\ +set DOTNET_CMD=%DOTNET_PATH%dotnet.exe +if [%BUILDTOOLS_SOURCE%]==[] set BUILDTOOLS_SOURCE=https://www.myget.org/F/dotnet-buildtools/ +set /P BUILDTOOLS_VERSION=< "%~dp0BuildToolsVersion.txt" +set BUILD_TOOLS_PATH=%PACKAGES_DIR%Microsoft.DotNet.BuildTools\%BUILDTOOLS_VERSION%\lib\ +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] ( + if exist "%TOOLRUNTIME_DIR%" rmdir /S /Q "%TOOLRUNTIME_DIR%" + if exist "%PACKAGES_DIR%Microsoft.DotNet.BuildTools" rmdir /S /Q "%PACKAGES_DIR%Microsoft.DotNet.BuildTools" +) + +:: If sempahore exists do nothing +if exist "%BUILD_TOOLS_SEMAPHORE%" ( + echo Tools are already initialized. + goto :DONE +) + +if exist "%TOOLRUNTIME_DIR%" rmdir /S /Q "%TOOLRUNTIME_DIR%" + +:: Download Nuget.exe +if NOT exist "%PACKAGES_DIR%NuGet.exe" ( + if NOT exist "%PACKAGES_DIR%" mkdir "%PACKAGES_DIR%" + powershell -NoProfile -ExecutionPolicy unrestricted -Command "(New-Object Net.WebClient).DownloadFile('https://www.nuget.org/nuget.exe', '%PACKAGES_DIR%NuGet.exe') +) + +if NOT exist "%PROJECT_JSON_PATH%" mkdir "%PROJECT_JSON_PATH%" +echo %PROJECT_JSON_CONTENTS% > "%PROJECT_JSON_FILE%" +echo Running %0 > "%INIT_TOOLS_LOG%" + +if exist "%DOTNET_CMD%" goto :afterdotnetrestore + +echo Installing dotnet cli... +if NOT exist "%DOTNET_PATH%" mkdir "%DOTNET_PATH%" +set /p DOTNET_VERSION=< "%~dp0DotnetCLIVersion.txt" +if [%PROCESSOR_ARCHITECTURE%]==[x86] (set DOTNET_ZIP_NAME=dotnet-dev-win-x86.%DOTNET_VERSION%.zip) else (set DOTNET_ZIP_NAME=dotnet-dev-win-x64.%DOTNET_VERSION%.zip) +set DOTNET_REMOTE_PATH=https://dotnetcli.blob.core.windows.net/dotnet/preview/Binaries/%DOTNET_VERSION%/%DOTNET_ZIP_NAME% +set DOTNET_LOCAL_PATH=%DOTNET_PATH%%DOTNET_ZIP_NAME% +echo Installing '%DOTNET_REMOTE_PATH%' to '%DOTNET_LOCAL_PATH%' >> "%INIT_TOOLS_LOG%" +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%" +if NOT exist "%DOTNET_LOCAL_PATH%" ( + echo ERROR: Could not install dotnet cli correctly. See '%INIT_TOOLS_LOG%' for more details. + set TOOLS_INIT_RETURN_CODE=1 + goto :DONE +) + +:afterdotnetrestore + +if exist "%BUILD_TOOLS_PATH%" goto :afterbuildtoolsrestore +echo Restoring BuildTools version %BUILDTOOLS_VERSION%... +echo Running: "%DOTNET_CMD%" restore "%PROJECT_JSON_FILE%" --packages "%PACKAGES_DIR% " --source "%BUILDTOOLS_SOURCE%" >> "%INIT_TOOLS_LOG%" +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. + set TOOLS_INIT_RETURN_CODE=1 + goto :DONE +) + +:afterbuildtoolsrestore + +echo Initializing BuildTools ... +echo Running: "%BUILD_TOOLS_PATH%init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" >> "%INIT_TOOLS_LOG%" +call "%BUILD_TOOLS_PATH%init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" >> "%INIT_TOOLS_LOG%" + +:: Create sempahore file +echo Done initializing tools. +echo Init-Tools.cmd completed for BuildTools Version: %BUILDTOOLS_VERSION% > "%BUILD_TOOLS_SEMAPHORE%" + +:DONE + +exit /b %TOOLS_INIT_RETURN_CODE% |