Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 684a161

Browse files
authored
Port of #12795 to release/1.0.0 (#12941)
1 parent 4a22d95 commit 684a161

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

init-tools.cmd

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ set PROJECT_JSON_PATH=%TOOLRUNTIME_DIR%\%BUILDTOOLS_VERSION%
1313
set PROJECT_JSON_FILE=%PROJECT_JSON_PATH%\project.json
1414
set PROJECT_JSON_CONTENTS={ "dependencies": { "Microsoft.DotNet.BuildTools": "%BUILDTOOLS_VERSION%" , "Microsoft.DotNet.BuildTools.Coreclr": "1.0.4-prerelease"}, "frameworks": { "dnxcore50": { } } }
1515
set BUILD_TOOLS_SEMAPHORE=%PROJECT_JSON_PATH%\init-tools.completed
16-
set TOOLS_INIT_RETURN_CODE=0
1716

1817
:: if force option is specified then clean the tool runtime and build tools package directory to force it to get recreated
1918
if [%1]==[force] (
2019
if exist "%TOOLRUNTIME_DIR%" rmdir /S /Q "%TOOLRUNTIME_DIR%"
2120
if exist "%PACKAGES_DIR%Microsoft.DotNet.BuildTools" rmdir /S /Q "%PACKAGES_DIR%Microsoft.DotNet.BuildTools"
2221
)
2322

24-
:: If sempahore exists do nothing
23+
:: If semaphore exists do nothing
2524
if exist "%BUILD_TOOLS_SEMAPHORE%" (
2625
echo Tools are already initialized.
2726
goto :DONE
@@ -50,9 +49,8 @@ set DOTNET_LOCAL_PATH=%DOTNET_PATH%%DOTNET_ZIP_NAME%
5049
echo Installing '%DOTNET_REMOTE_PATH%' to '%DOTNET_LOCAL_PATH%' >> "%INIT_TOOLS_LOG%"
5150
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%"
5251
if NOT exist "%DOTNET_LOCAL_PATH%" (
53-
echo ERROR: Could not install dotnet cli correctly. See '%INIT_TOOLS_LOG%' for more details.
54-
set TOOLS_INIT_RETURN_CODE=1
55-
goto :DONE
52+
echo ERROR: Could not install dotnet cli correctly. 1>&2
53+
goto :error
5654
)
5755

5856
:afterdotnetrestore
@@ -62,9 +60,8 @@ echo Restoring BuildTools version %BUILDTOOLS_VERSION%...
6260
echo Running: "%DOTNET_CMD%" restore "%PROJECT_JSON_FILE%" --packages "%PACKAGES_DIR% " --source "%BUILDTOOLS_SOURCE%" >> "%INIT_TOOLS_LOG%"
6361
call "%DOTNET_CMD%" restore "%PROJECT_JSON_FILE%" --packages "%PACKAGES_DIR% " --source "%BUILDTOOLS_SOURCE%" >> "%INIT_TOOLS_LOG%"
6462
if NOT exist "%BUILD_TOOLS_PATH%init-tools.cmd" (
65-
echo ERROR: Could not restore build tools correctly. See '%INIT_TOOLS_LOG%' for more details.
66-
set TOOLS_INIT_RETURN_CODE=1
67-
goto :DONE
63+
echo ERROR: Could not restore build tools correctly. 1>&2
64+
goto :error
6865
)
6966

7067
:afterbuildtoolsrestore
@@ -73,10 +70,13 @@ echo Initializing BuildTools ...
7370
echo Running: "%BUILD_TOOLS_PATH%init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" >> "%INIT_TOOLS_LOG%"
7471
call "%BUILD_TOOLS_PATH%init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" >> "%INIT_TOOLS_LOG%"
7572

76-
:: Create sempahore file
73+
:: Create semaphore file
74+
:DONE
7775
echo Done initializing tools.
7876
echo Init-Tools.cmd completed for BuildTools Version: %BUILDTOOLS_VERSION% > "%BUILD_TOOLS_SEMAPHORE%"
77+
exit /b 0
7978

80-
:DONE
81-
82-
exit /b %TOOLS_INIT_RETURN_CODE%
79+
:error
80+
echo Please check the detailed log that follows. 1>&2
81+
type "%INIT_TOOLS_LOG%" 1>&2
82+
exit /b 1

init-tools.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ if [ -z "$HOME" ]; then
2525
echo "HOME not defined; setting it to $HOME"
2626
fi
2727

28+
__init_tools_log=$__scriptpath/init-tools.log
2829
__PACKAGES_DIR=$__scriptpath/packages
2930
__TOOLRUNTIME_DIR=$__scriptpath/Tools
3031
__DOTNET_PATH=$__TOOLRUNTIME_DIR/dotnetcli
@@ -64,6 +65,12 @@ case $OSName in
6465
;;
6566
esac
6667

68+
display_error_message()
69+
{
70+
echo "Please check the detailed log that follows." 1>&2
71+
cat "$__init_tools_log" 1>&2
72+
}
73+
6774
# Initialize Linux Distribution name and .NET CLI package name.
6875

6976
initDistroName $OS
@@ -85,6 +92,7 @@ if [ ! -e $__PROJECT_JSON_FILE ]; then
8592

8693
if [ ! -e $__DOTNET_PATH ]; then
8794
# curl has HTTPS CA trust-issues less often than wget, so lets try that first.
95+
echo "Installing '${__CLIDownloadURL}' to '$__DOTNET_PATH/dotnet.tar'" >> $__init_tools_log
8896
which curl > /dev/null 2> /dev/null
8997
if [ $? -ne 0 ]; then
9098
mkdir -p "$__DOTNET_PATH"
@@ -110,11 +118,25 @@ if [ ! -e $__PROJECT_JSON_FILE ]; then
110118
echo $__PROJECT_JSON_CONTENTS > "$__PROJECT_JSON_FILE"
111119

112120
if [ ! -e $__BUILD_TOOLS_PATH ]; then
113-
$__DOTNET_CMD restore "$__PROJECT_JSON_FILE" --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE
121+
echo "Running: $__DOTNET_CMD restore "$__PROJECT_JSON_FILE" --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE" >> $__init_tools_log
122+
$__DOTNET_CMD restore "$__PROJECT_JSON_FILE" --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE >> $__init_tools_log
123+
fi
124+
125+
if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then
126+
echo "ERROR: Could not restore build tools correctly." 1>&2
127+
display_error_message
114128
fi
115129

130+
echo "Initializing BuildTools..."
131+
echo "Running: $__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR" >> $__init_tools_log
116132
# On ubuntu 14.04, /bin/sh (symbolic link) calls /bin/dash by default.
117-
$__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR
133+
$__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR >> $__init_tools_log
134+
135+
if [ "$?" != "0" ]; then
136+
echo "ERROR: An error occurred when trying to initialize the tools." 1>&2
137+
display_error_message
138+
exit 1
139+
fi
118140

119141
chmod a+x $__TOOLRUNTIME_DIR/corerun
120142
else

0 commit comments

Comments
 (0)