From 90c08691332513adbe6806b5377b25ee5e9e14ef Mon Sep 17 00:00:00 2001 From: Elinor Fung <47805090+elinor-fung@users.noreply.github.com> Date: Mon, 5 Aug 2019 22:36:20 -0700 Subject: [PATCH] Prefix error messages in init-tools to make them Azure DevOps logging commands (dotnet/coreclr#26021) Commit migrated from https://github.com/dotnet/coreclr/commit/fe31eb52cca002ab3046d49c9f7fde1a422eb505 --- src/coreclr/init-tools.cmd | 15 ++++++++++----- src/coreclr/init-tools.sh | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/coreclr/init-tools.cmd b/src/coreclr/init-tools.cmd index 0905e913b96..5d573348696 100644 --- a/src/coreclr/init-tools.cmd +++ b/src/coreclr/init-tools.cmd @@ -17,6 +17,11 @@ set INIT_TOOLS_RESTORE_PROJECT=%~dp0init-tools.msbuild set BUILD_TOOLS_SEMAPHORE_DIR=%TOOLRUNTIME_DIR%\%BUILDTOOLS_VERSION% set BUILD_TOOLS_SEMAPHORE=%BUILD_TOOLS_SEMAPHORE_DIR%\init-tools.completed +REM Set variables used when running in an Azure DevOps task +if defined TF_BUILD ( + set __ErrMsgPrefix=##vso[task.logissue type=error] +) + :: 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%" @@ -36,7 +41,7 @@ if exist "%DotNetBuildToolsDir%" ( mklink /j "%TOOLRUNTIME_DIR%" "%DotNetBuildToolsDir%" if not exist "%DOTNET_CMD%" ( - echo ERROR: Ensure that '%DotNetBuildToolsDir%' contains the .NET Core SDK at '%DOTNET_PATH%' + echo %__ErrMsgPrefix%ERROR: Ensure that '%DotNetBuildToolsDir%' contains the .NET Core SDK at '%DOTNET_PATH%' exit /b 1 ) @@ -54,7 +59,7 @@ if exist "%DOTNET_CMD%" goto :afterdotnetrestore REM Use x86 tools on arm64 and x86. REM arm32 host is not currently supported, please crossbuild. if /i "%PROCESSOR_ARCHITECTURE%" == "arm" ( - echo "Error, arm32 arch not supported for build tools." + echo %__ErrMsgPrefix%ERROR: arm32 arch not supported for build tools. exit /b 1 ) @@ -78,7 +83,7 @@ echo "init-tools.cmd: Setting arch to %_Arch% for build tools" if NOT exist "%DOTNET_CMD%" ( call %~dp0init-dotnet.cmd if NOT exist "%DOTNET_CMD%" ( - echo ERROR: Could not install dotnet cli correctly. 1>&2 + echo %__ErrMsgPrefix%ERROR: Could not install dotnet cli correctly. Expected to be installed at %DOTNET_CMD% 1>&2 goto :error ) ) @@ -99,7 +104,7 @@ echo Restoring BuildTools version %BUILDTOOLS_VERSION%... echo Running: "%DOTNET_CMD%" restore "%INIT_TOOLS_RESTORE_PROJECT%" --no-cache --packages "%PACKAGES_DIR%" --source "%BUILDTOOLS_SOURCE%" /p:BuildToolsPackageVersion=%BUILDTOOLS_VERSION% /p:ToolsDir=%TOOLRUNTIME_DIR% >> "%INIT_TOOLS_LOG%" call "%DOTNET_CMD%" restore "%INIT_TOOLS_RESTORE_PROJECT%" --no-cache --packages "%PACKAGES_DIR%" --source "%BUILDTOOLS_SOURCE%" /p:BuildToolsPackageVersion=%BUILDTOOLS_VERSION% /p:ToolsDir=%TOOLRUNTIME_DIR% >> "%INIT_TOOLS_LOG%" if NOT exist "%BUILD_TOOLS_PATH%\init-tools.cmd" ( - echo ERROR: Could not restore build tools correctly. 1>&2 + echo %__ErrMsgPrefix%ERROR: Could not restore build tools correctly. 1>&2 goto :error ) @@ -113,7 +118,7 @@ echo Running: "%BUILD_TOOLS_PATH%\init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLR call "%BUILD_TOOLS_PATH%\init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" "%PACKAGES_DIR%" >> "%INIT_TOOLS_LOG%" set INIT_TOOLS_ERRORLEVEL=%ERRORLEVEL% if not [%INIT_TOOLS_ERRORLEVEL%]==[0] ( - echo ERROR: An error occured when trying to initialize the tools. 1>&2 + echo %__ErrMsgPrefix%ERROR: An error occurred when trying to initialize the tools. 1>&2 goto :error ) diff --git a/src/coreclr/init-tools.sh b/src/coreclr/init-tools.sh index 42bbc0972ff..b0c03543eab 100755 --- a/src/coreclr/init-tools.sh +++ b/src/coreclr/init-tools.sh @@ -15,6 +15,11 @@ __BUILD_TOOLS_PATH="$__PACKAGES_DIR/microsoft.dotnet.buildtools/$__BUILD_TOOLS_P __INIT_TOOLS_RESTORE_PROJECT="$__scriptpath/init-tools.msbuild" __BUILD_TOOLS_SEMAPHORE="$__TOOLRUNTIME_DIR/$__BUILD_TOOLS_PACKAGE_VERSION/init-tools.complete" +# Set variables used when running in an Azure DevOps task +if [[ ! -z $TF_BUILD ]]; then + __ErrMsgPrefix="##vso[task.logissue type=error]" +fi + if [ -e "$__BUILD_TOOLS_SEMAPHORE" ]; then echo "Tools are already initialized" return #return instead of exit because this script is inlined in other scripts which we don't want to exit @@ -27,7 +32,7 @@ if [ -d "${DotNetBuildToolsDir:-}" ]; then ln -s "$DotNetBuildToolsDir" "$__TOOLRUNTIME_DIR" if [ ! -e "$__DOTNET_CMD" ]; then - echo "ERROR: Ensure that $DotNetBuildToolsDir contains the .NET Core SDK at $__DOTNET_PATH" + echo "${__ErrMsgPrefix}ERROR: Ensure that $DotNetBuildToolsDir contains the .NET Core SDK at $__DOTNET_PATH" exit 1 fi @@ -90,7 +95,7 @@ case $OSName in # Format x.y.z as single integer with three digits for each part VERSION=`sw_vers -productVersion| sed -e 's/\./ /g' | xargs printf "%03d%03d%03d"` if [ "$VERSION" -lt 010012000 ]; then - echo error: macOS version `sw_vers -productVersion` is too old. 10.12 is needed as minimum. + echo ${__ErrMsgPrefix}ERROR: macOS version `sw_vers -productVersion` is too old. 10.12 is needed as minimum. exit 1 fi ;; @@ -133,7 +138,7 @@ __PKG_RID=$__PKG_RID-$__PKG_ARCH if [ ! -e "$__DOTNET_CMD" ]; then source $__scriptpath/init-dotnet.sh if [ ! -e "$__DOTNET_CMD" ]; then - echo "ERROR: Ensure arcade dotnet install did not install dotnet at $__DOTNET_CMD" + echo "${__ErrMsgPrefix}ERROR: Could not install dotnet cli correctly. Expected to be installed at $__DOTNET_CMD" exit 1 fi fi @@ -143,7 +148,7 @@ if [ ! -e "$__BUILD_TOOLS_PATH" ]; then echo "Running: $__DOTNET_CMD restore \"$__INIT_TOOLS_RESTORE_PROJECT\" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE /p:BuildToolsPackageVersion=$__BUILD_TOOLS_PACKAGE_VERSION /p:ToolsDir=$__TOOLRUNTIME_DIR" >> "$__init_tools_log" "$__DOTNET_CMD" restore "$__INIT_TOOLS_RESTORE_PROJECT" --no-cache --packages "$__PACKAGES_DIR" --source "$__BUILDTOOLS_SOURCE" /p:BuildToolsPackageVersion=$__BUILD_TOOLS_PACKAGE_VERSION /p:ToolsDir="$__TOOLRUNTIME_DIR" >> "$__init_tools_log" if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then - echo "ERROR: Could not restore build tools correctly." 1>&2 + echo "${__ErrMsgPrefix}ERROR: Could not restore build tools correctly." 1>&2 display_error_message fi fi @@ -173,7 +178,7 @@ else chmod +x "$__BUILD_TOOLS_PATH/init-tools.sh" "$__BUILD_TOOLS_PATH/init-tools.sh" "$__scriptpath" "$__DOTNET_CMD" "$__TOOLRUNTIME_DIR" "$__PACKAGES_DIR" >> "$__init_tools_log" if [ "$?" != "0" ]; then - echo "ERROR: An error occurred when trying to initialize the tools." 1>&2 + echo "${__ErrMsgPrefix}ERROR: An error occurred when trying to initialize the tools." 1>&2 display_error_message exit 1 fi -- 2.34.1