-__BUILD_TOOLS_PACKAGE_VERSION=$(cat $__scriptpath/BuildToolsVersion.txt)
-__DOTNET_TOOLS_VERSION=$(cat $__scriptpath/DotnetCLIVersion.txt)
-__BUILD_TOOLS_PATH=$__PACKAGES_DIR/microsoft.dotnet.buildtools/$__BUILD_TOOLS_PACKAGE_VERSION/lib
-__INIT_TOOLS_RESTORE_PROJECT=$__scriptpath/init-tools.msbuild
-__INIT_TOOLS_DONE_MARKER_DIR=$__TOOLRUNTIME_DIR/$__BUILD_TOOLS_PACKAGE_VERSION
-__INIT_TOOLS_DONE_MARKER=$__INIT_TOOLS_DONE_MARKER_DIR/done
-
-if [ -z "$__DOTNET_PKG" ]; then
- if [ "$(uname -m | grep "i[3456]86")" = "i686" ]; then
- echo "Error: build not supported on 32 bit Unix"
- exit 1
- fi
- OSName=$(uname -s)
- case $OSName in
- Darwin)
- OS=OSX
- __DOTNET_PKG=dotnet-dev-osx-x64
- ulimit -n 2048
- # 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.
- exit 1
- fi
- ;;
-
- Linux)
- __DOTNET_PKG=dotnet-dev-linux-x64
- OS=Linux
-
- if [ -e /etc/os-release ]; then
- source /etc/os-release
- if [[ $ID == "alpine" ]]; then
- # remove the last version digit
- VERSION_ID=${VERSION_ID%.*}
- __DOTNET_PKG=dotnet-dev-alpine.$VERSION_ID-x64
- fi
+__BUILD_TOOLS_PACKAGE_VERSION=$(cat "$__scriptpath/BuildToolsVersion.txt" | sed 's/\r$//') # remove CR if mounted repo on Windows drive
+__DOTNET_TOOLS_VERSION=$(cat "$__scriptpath/DotnetCLIVersion.txt" | sed 's/\r$//') # remove CR if mounted repo on Windows drive
+__ILASM_VERSION=$(cat "$__scriptpath/ILAsmVersion.txt" | sed 's/\r$//') # remove CR if mounted repo on Windows drive
+__BUILD_TOOLS_PATH="$__PACKAGES_DIR/microsoft.dotnet.buildtools/$__BUILD_TOOLS_PACKAGE_VERSION/lib"
+__INIT_TOOLS_RESTORE_PROJECT="$__scriptpath/init-tools.msbuild"
+__BUILD_TOOLS_SEMAPHORE="$__TOOLRUNTIME_DIR/$__BUILD_TOOLS_PACKAGE_VERSION/init-tools.complete"
+
+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
+fi