Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions init-tools.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ 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 semaphore exists do nothing
if exist "%BUILD_TOOLS_SEMAPHORE%" (
echo Tools are already initialized.
goto :DONE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Master has :EOF here, rather than :DONE. This PR removes the DONE label, resulting in failures when tools are already initialized.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Expand Down Expand Up @@ -50,9 +49,8 @@ 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 "(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.
set TOOLS_INIT_RETURN_CODE=1
goto :DONE
echo ERROR: Could not install dotnet cli correctly. 1>&2
goto :error
)

:afterdotnetrestore
Expand All @@ -62,9 +60,8 @@ 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
echo ERROR: Could not restore build tools correctly. 1>&2
goto :error
)

:afterbuildtoolsrestore
Expand All @@ -73,10 +70,13 @@ 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
:: Create semaphore file
:DONE
echo Done initializing tools.
echo Init-Tools.cmd completed for BuildTools Version: %BUILDTOOLS_VERSION% > "%BUILD_TOOLS_SEMAPHORE%"
exit /b 0

:DONE

exit /b %TOOLS_INIT_RETURN_CODE%
:error
echo Please check the detailed log that follows. 1>&2
type "%INIT_TOOLS_LOG%" 1>&2
exit /b 1
26 changes: 24 additions & 2 deletions init-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if [ -z "$HOME" ]; then
echo "HOME not defined; setting it to $HOME"
fi

__init_tools_log=$__scriptpath/init-tools.log
__PACKAGES_DIR=$__scriptpath/packages
__TOOLRUNTIME_DIR=$__scriptpath/Tools
__DOTNET_PATH=$__TOOLRUNTIME_DIR/dotnetcli
Expand Down Expand Up @@ -64,6 +65,12 @@ case $OSName in
;;
esac

display_error_message()
{
echo "Please check the detailed log that follows." 1>&2
cat "$__init_tools_log" 1>&2
}

# Initialize Linux Distribution name and .NET CLI package name.

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

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

if [ ! -e $__BUILD_TOOLS_PATH ]; then
$__DOTNET_CMD restore "$__PROJECT_JSON_FILE" --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE
echo "Running: $__DOTNET_CMD restore "$__PROJECT_JSON_FILE" --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE" >> $__init_tools_log
$__DOTNET_CMD restore "$__PROJECT_JSON_FILE" --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE >> $__init_tools_log
fi

if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then
echo "ERROR: Could not restore build tools correctly." 1>&2
display_error_message
fi

echo "Initializing BuildTools..."
echo "Running: $__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR" >> $__init_tools_log
# On ubuntu 14.04, /bin/sh (symbolic link) calls /bin/dash by default.
$__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR
$__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR >> $__init_tools_log

if [ "$?" != "0" ]; then
echo "ERROR: An error occurred when trying to initialize the tools." 1>&2
display_error_message
exit 1
fi

chmod a+x $__TOOLRUNTIME_DIR/corerun
else
Expand Down