2015-10-15 12:18:45 -07:00
@ echo off
setlocal
REM Build 'dotnet' using a version of itself hosted on the DNX
REM The output of this is independent of DNX
REM This trick gets the absolute path from a relative path
pushd %~dp0 ..
set REPOROOT = %CD%
popd
2015-10-16 16:55:47 -07:00
set RID = win7-x64
set STAGE0_DIR = %REPOROOT% \artifacts\%RID% \stage0
set STAGE1_DIR = %REPOROOT% \artifacts\%RID% \stage1
set STAGE2_DIR = %REPOROOT% \artifacts\%RID% \stage2
2015-10-15 12:18:45 -07:00
where dnvm > nul 2 > nul
if %errorlevel% == 0 goto have_dnvm
REM download dnvm
2015-10-16 15:41:41 -07:00
echo Installing dnvm (DNU is needed to bootstrap currently for package restore) ...
2015-10-15 12:18:45 -07:00
powershell -NoProfile -ExecutionPolicy Unrestricted -Command " &{$Branch='dev';$wc=New-Object System.Net.WebClient;$wc.Proxy=[System.Net.WebRequest]::DefaultWebProxy;$wc.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;Invoke-Expression ($wc.DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))} "
: have_dnvm
echo Installing and use-ing the latest CoreCLR x64 DNX ...
2015-10-17 01:20:45 -07:00
call dnvm install -nonative -u latest -r coreclr -arch x64 -alias dotnet_bootstrap
2015-10-15 12:18:45 -07:00
if errorlevel 1 goto fail
call dnvm use dotnet_bootstrap -r coreclr -arch x64
if errorlevel 1 goto fail
if exist %STAGE1_DIR% rd /s /q %STAGE1_DIR%
echo Running 'dnu restore' to restore packages for DNX-hosted projects
2015-10-16 16:55:47 -07:00
call dnu restore " %REPOROOT% "
2015-10-15 12:18:45 -07:00
if errorlevel 1 goto fail
2015-10-16 15:41:41 -07:00
echo Building basic dotnet tools using older dotnet SDK version
set DOTNET_HOME = %STAGE0_DIR%
call %~dp0 dnvm2 upgrade
if errorlevel 1 goto fail
2015-10-15 12:18:45 -07:00
echo Building stage1 dotnet.exe ...
2015-10-16 16:55:47 -07:00
dotnet-publish --framework dnxcore50 --runtime %RID% --output " %STAGE1_DIR% " " %REPOROOT% \src\Microsoft.DotNet.Cli "
2015-10-15 12:18:45 -07:00
if errorlevel 1 goto fail
echo Building stage1 dotnet-compile.exe ...
2015-10-16 16:55:47 -07:00
dotnet-publish --framework dnxcore50 --runtime %RID% --output " %STAGE1_DIR% " " %REPOROOT% \src\Microsoft.DotNet.Tools.Compiler "
2015-10-15 12:18:45 -07:00
if errorlevel 1 goto fail
echo Building stage1 dotnet-publish.exe ...
2015-10-16 16:55:47 -07:00
dotnet-publish --framework dnxcore50 --runtime %RID% --output " %STAGE1_DIR% " " %REPOROOT% \src\Microsoft.DotNet.Tools.Publish "
2015-10-15 12:18:45 -07:00
if errorlevel 1 goto fail
echo Re-building dotnet tools with the bootstrapped version
REM This should move into a proper build script of some kind once we are bootstrapped
set PATH = %STAGE1_DIR% ;%PATH%
if exist %STAGE2_DIR% rd /s /q %STAGE2_DIR%
2015-10-16 16:25:54 -07:00
REM This works around the coreconsole bug where the path to the exe can't be found
pushd
cd %STAGE1_DIR%
2015-10-16 04:21:40 -07:00
2015-10-15 12:18:45 -07:00
echo Building stage2 dotnet.exe ...
2015-10-16 16:55:47 -07:00
dotnet publish --framework dnxcore50 --runtime %RID% --output " %STAGE2_DIR% " " %REPOROOT% \src\Microsoft.DotNet.Cli "
2015-10-15 12:18:45 -07:00
if errorlevel 1 goto fail
echo Building stage2 dotnet-compile.exe ...
2015-10-16 16:55:47 -07:00
dotnet publish --framework dnxcore50 --runtime %RID% --output " %STAGE2_DIR% " " %REPOROOT% \src\Microsoft.DotNet.Tools.Compiler "
2015-10-15 12:18:45 -07:00
if errorlevel 1 goto fail
echo Building stage2 dotnet-publish.exe ...
2015-10-16 16:55:47 -07:00
dotnet publish --framework dnxcore50 --runtime %RID% --output " %STAGE2_DIR% " " %REPOROOT% \src\Microsoft.DotNet.Tools.Publish "
2015-10-15 12:18:45 -07:00
if errorlevel 1 goto fail
echo Bootstrapped dotnet to %STAGE2_DIR%
2015-10-16 04:21:40 -07:00
popd
2015-10-15 12:18:45 -07:00
goto end
: fail
echo Bootstrapping failed...
exit /B 1
2015-10-16 16:25:54 -07:00
: end