Skip to content

Commit 09b8ffd

Browse files
authored
Merge pull request #235 from weshaggard/UpdateTools
Update tools
2 parents 16b1cbe + bcdd631 commit 09b8ffd

File tree

5 files changed

+105
-102
lines changed

5 files changed

+105
-102
lines changed

DotnetCLIVersion.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0-preview3-006845
1+
2.0.0

init-tools.cmd

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ if exist "%BUILD_TOOLS_SEMAPHORE%" (
2626

2727
if exist "%TOOLRUNTIME_DIR%" rmdir /S /Q "%TOOLRUNTIME_DIR%"
2828

29+
if exist "%DotNetBuildToolsDir%" (
30+
echo Using tools from '%DotNetBuildToolsDir%'.
31+
mklink /j "%TOOLRUNTIME_DIR%" "%DotNetBuildToolsDir%"
32+
33+
if not exist "%DOTNET_CMD%" (
34+
echo ERROR: Ensure that '%DotNetBuildToolsDir%' contains the .NET Core SDK at '%DOTNET_PATH%'
35+
exit /b 1
36+
)
37+
38+
echo Done initializing tools.
39+
echo Using tools from '%DotNetBuildToolsDir%'. > "%BUILD_TOOLS_SEMAPHORE%"
40+
exit /b 0
41+
)
42+
2943
echo Running %0 > "%INIT_TOOLS_LOG%"
3044

3145
set /p DOTNET_VERSION=< "%~dp0DotnetCLIVersion.txt"
@@ -56,11 +70,6 @@ if NOT exist "%BUILD_TOOLS_PATH%init-tools.cmd" (
5670

5771
:afterbuildtoolsrestore
5872

59-
:: Temporarily fix up BuildTools to work with the current CLI version
60-
set BUILDTOOLS_PROJECT=%BUILD_TOOLS_PATH%tool-runtime\project.csproj
61-
echo Fixing up %BUILDTOOLS_PROJECT%
62-
powershell -NoProfile -ExecutionPolicy unrestricted -Command "$newFileContent = Get-Content '%BUILDTOOLS_PROJECT%'; $newFileContent = $newFileContent -replace \".*^<PackageTargetFallback.*\", \"^<NoWarn^>NU1605^</NoWarn^>\"; $newFileContent | Out-File '%BUILDTOOLS_PROJECT%'"
63-
6473
echo Initializing BuildTools...
6574
echo Running: "%BUILD_TOOLS_PATH%init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" >> "%INIT_TOOLS_LOG%"
6675
call "%BUILD_TOOLS_PATH%init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" >> "%INIT_TOOLS_LOG%"

init-tools.sh

Lines changed: 88 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -12,115 +12,109 @@ __BUILD_TOOLS_PACKAGE_VERSION=$(cat $__scriptpath/BuildToolsVersion.txt)
1212
__DOTNET_TOOLS_VERSION=$(cat $__scriptpath/DotnetCLIVersion.txt)
1313
__BUILD_TOOLS_PATH=$__PACKAGES_DIR/microsoft.dotnet.buildtools/$__BUILD_TOOLS_PACKAGE_VERSION/lib
1414
__INIT_TOOLS_RESTORE_PROJECT=$__scriptpath/init-tools.msbuild
15-
__INIT_TOOLS_DONE_MARKER_DIR=$__TOOLRUNTIME_DIR/$__BUILD_TOOLS_PACKAGE_VERSION
16-
__INIT_TOOLS_DONE_MARKER=$__INIT_TOOLS_DONE_MARKER_DIR/done
15+
__BUILD_TOOLS_SEMAPHORE=$__TOOLRUNTIME_DIR/$__BUILD_TOOLS_PACKAGE_VERSION/init-tools.complete
1716

18-
export DOTNET_CLI_TELEMETRY_OPTOUT=1
19-
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
17+
if [ -e $__BUILD_TOOLS_SEMAPHORE ]; then
18+
echo "Tools are already initialized"
19+
return #return instead of exit because this script is inlined in other scripts which we don't want to exit
20+
fi
21+
22+
if [ -e $__TOOLRUNTIME_DIR ]; then rm -rf -- $__TOOLRUNTIME_DIR; fi
2023

21-
if [ -z "$__DOTNET_PKG" ]; then
22-
if [ "$(uname -m | grep "i[3456]86")" = "i686" ]; then
23-
echo "Warning: build not supported on 32 bit Unix"
24+
if [ -d "$DotNetBuildToolsDir" ]; then
25+
echo "Using tools from '$DotNetBuildToolsDir'."
26+
ln -s "$DotNetBuildToolsDir" "$__TOOLRUNTIME_DIR"
27+
28+
if [ ! -e "$__DOTNET_CMD" ]; then
29+
echo "ERROR: Ensure that $DotNetBuildToolsDir contains the .NET Core SDK at $__DOTNET_PATH"
30+
exit 1
2431
fi
25-
OSName=$(uname -s)
26-
case $OSName in
27-
Darwin)
28-
OS=OSX
29-
__DOTNET_PKG=dotnet-sdk-${__DOTNET_TOOLS_VERSION}-osx-x64
30-
ulimit -n 2048
31-
;;
32-
33-
Linux)
34-
__DOTNET_PKG=dotnet-sdk-${__DOTNET_TOOLS_VERSION}-linux-x64
35-
OS=Linux
36-
;;
37-
38-
*)
39-
echo "Unsupported OS '$OSName' detected. Downloading linux-x64 tools."
40-
OS=Linux
41-
__DOTNET_PKG=dotnet-sdk-${__DOTNET_TOOLS_VERSION}-linux-x64
42-
;;
43-
esac
32+
33+
echo "Done initializing tools."
34+
mkdir -p "$(dirname "$__BUILD_TOOLS_SEMAPHORE")" && touch $__BUILD_TOOLS_SEMAPHORE
35+
return #return instead of exit because this script is inlined in other scripts which we don't want to exit
4436
fi
4537

46-
if [ ! -e $__INIT_TOOLS_DONE_MARKER ]; then
47-
__PATCH_CLI_NUGET_FRAMEWORKS=0
48-
49-
if [ -e $__TOOLRUNTIME_DIR ]; then rm -rf -- $__TOOLRUNTIME_DIR; fi
50-
echo "Running: $__scriptpath/init-tools.sh" > $__init_tools_log
51-
52-
if [ ! -e $__DOTNET_PATH ]; then
53-
54-
mkdir -p "$__DOTNET_PATH"
55-
56-
if [ -n "$DOTNET_TOOLSET_DIR" ] && [ -d "$DOTNET_TOOLSET_DIR/$__DOTNET_TOOLS_VERSION" ]; then
57-
echo "Copying $DOTNET_TOOLSET_DIR/$__DOTNET_TOOLS_VERSION to $__DOTNET_PATH" >> $__init_tools_log
58-
cp -r $DOTNET_TOOLSET_DIR/$__DOTNET_TOOLS_VERSION/* $__DOTNET_PATH
59-
elif [ -n "$DOTNET_TOOL_DIR" ] && [ -d "$DOTNET_TOOL_DIR" ]; then
60-
echo "Copying $DOTNET_TOOL_DIR to $__DOTNET_PATH" >> $__init_tools_log
61-
cp -r $DOTNET_TOOL_DIR/* $__DOTNET_PATH
62-
else
63-
echo "Installing dotnet cli..."
64-
__DOTNET_LOCATION="https://dotnetcli.azureedge.net/dotnet/Sdk/${__DOTNET_TOOLS_VERSION}/${__DOTNET_PKG}.tar.gz"
65-
# curl has HTTPS CA trust-issues less often than wget, so lets try that first.
66-
echo "Installing '${__DOTNET_LOCATION}' to '$__DOTNET_PATH/dotnet.tar'" >> $__init_tools_log
67-
which curl > /dev/null 2> /dev/null
68-
if [ $? -ne 0 ]; then
69-
wget -q -O $__DOTNET_PATH/dotnet.tar ${__DOTNET_LOCATION}
70-
else
71-
curl --retry 10 -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar ${__DOTNET_LOCATION}
72-
fi
73-
cd $__DOTNET_PATH
74-
tar -xf $__DOTNET_PATH/dotnet.tar
75-
76-
cd $__scriptpath
77-
78-
__PATCH_CLI_NUGET_FRAMEWORKS=1
38+
echo "Running: $__scriptpath/init-tools.sh" > $__init_tools_log
39+
40+
if [ ! -e $__DOTNET_PATH ]; then
41+
if [ -z "$__DOTNET_PKG" ]; then
42+
if [ "$(uname -m | grep "i[3456]86")" = "i686" ]; then
43+
echo "Warning: build not supported on 32 bit Unix"
7944
fi
45+
OSName=$(uname -s)
46+
case $OSName in
47+
Darwin)
48+
OS=OSX
49+
__DOTNET_PKG=dotnet-sdk-${__DOTNET_TOOLS_VERSION}-osx-x64
50+
ulimit -n 2048
51+
;;
52+
53+
Linux)
54+
__DOTNET_PKG=dotnet-sdk-${__DOTNET_TOOLS_VERSION}-linux-x64
55+
OS=Linux
56+
57+
if [ -e /etc/redhat-release ]; then
58+
redhatRelease=$(</etc/redhat-release)
59+
if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
60+
__DOTNET_PKG=dotnet-sdk-${__DOTNET_TOOLS_VERSION}-rhel.6-x64
61+
fi
62+
fi
63+
64+
;;
65+
66+
*)
67+
echo "Unsupported OS '$OSName' detected. Downloading linux-x64 tools."
68+
OS=Linux
69+
__DOTNET_PKG=dotnet-sdk-${__DOTNET_TOOLS_VERSION}-linux-x64
70+
;;
71+
esac
8072
fi
8173

74+
mkdir -p "$__DOTNET_PATH"
8275

83-
if [ -n "$BUILD_TOOLS_TOOLSET_DIR" ] && [ -d "$BUILD_TOOLS_TOOLSET_DIR/$__BUILD_TOOLS_PACKAGE_VERSION" ]; then
84-
echo "Copying $BUILD_TOOLS_TOOLSET_DIR/$__BUILD_TOOLS_PACKAGE_VERSION to $__TOOLRUNTIME_DIR" >> $__init_tools_log
85-
cp -r $BUILD_TOOLS_TOOLSET_DIR/$__BUILD_TOOLS_PACKAGE_VERSION/* $__TOOLRUNTIME_DIR
86-
elif [ -n "$BUILD_TOOLS_TOOL_DIR" ] && [ -d "$BUILD_TOOLS_TOOL_DIR" ]; then
87-
echo "Copying $BUILD_TOOLS_TOOL_DIR to $__TOOLRUNTIME_DIR" >> $__init_tools_log
88-
cp -r $BUILD_TOOLS_TOOL_DIR/* $__TOOLRUNTIME_DIR
76+
echo "Installing dotnet cli..."
77+
__DOTNET_LOCATION="https://dotnetcli.azureedge.net/dotnet/Sdk/${__DOTNET_TOOLS_VERSION}/${__DOTNET_PKG}.tar.gz"
78+
# curl has HTTPS CA trust-issues less often than wget, so lets try that first.
79+
echo "Installing '${__DOTNET_LOCATION}' to '$__DOTNET_PATH/dotnet.tar'" >> $__init_tools_log
80+
which curl > /dev/null 2> /dev/null
81+
if [ $? -ne 0 ]; then
82+
wget -q -O $__DOTNET_PATH/dotnet.tar ${__DOTNET_LOCATION}
8983
else
90-
if [ ! -e $__BUILD_TOOLS_PATH ]; then
91-
echo "Restoring BuildTools version $__BUILD_TOOLS_PACKAGE_VERSION..."
92-
echo "Running: $__DOTNET_CMD restore \"$__INIT_TOOLS_RESTORE_PROJECT\" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE /p:BuildToolsPackageVersion=$__BUILD_TOOLS_PACKAGE_VERSION" >> $__init_tools_log
93-
$__DOTNET_CMD restore "$__INIT_TOOLS_RESTORE_PROJECT" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE /p:BuildToolsPackageVersion=$__BUILD_TOOLS_PACKAGE_VERSION >> $__init_tools_log
94-
if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then echo "ERROR: Could not restore build tools correctly. See '$__init_tools_log' for more details."1>&2; fi
95-
fi
84+
curl --retry 10 -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar ${__DOTNET_LOCATION}
85+
fi
86+
cd $__DOTNET_PATH
87+
tar -xf $__DOTNET_PATH/dotnet.tar
9688

97-
sed -i '/.*<PackageTargetFallback.*/d' "$__BUILD_TOOLS_PATH/tool-runtime/project.csproj"
89+
cd $__scriptpath
90+
fi
9891

99-
echo "Initializing BuildTools..."
100-
echo "Running: $__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR" >> $__init_tools_log
92+
if [ ! -e $__BUILD_TOOLS_PATH ]; then
93+
echo "Restoring BuildTools version $__BUILD_TOOLS_PACKAGE_VERSION..."
94+
echo "Running: $__DOTNET_CMD restore \"$__INIT_TOOLS_RESTORE_PROJECT\" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE /p:BuildToolsPackageVersion=$__BUILD_TOOLS_PACKAGE_VERSION" >> $__init_tools_log
95+
$__DOTNET_CMD restore "$__INIT_TOOLS_RESTORE_PROJECT" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE /p:BuildToolsPackageVersion=$__BUILD_TOOLS_PACKAGE_VERSION >> $__init_tools_log
96+
if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then echo "ERROR: Could not restore build tools correctly. See '$__init_tools_log' for more details."1>&2; fi
97+
fi
10198

102-
# Executables restored with .NET Core 2.0 do not have executable permission flags. https://github.com/NuGet/Home/issues/4424
103-
chmod +x $__BUILD_TOOLS_PATH/init-tools.sh
104-
$__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR >> $__init_tools_log
105-
if [ "$?" != "0" ]; then
106-
echo "ERROR: An error occured when trying to initialize the tools. Please check '$__init_tools_log' for more details."1>&2
107-
exit 1
108-
fi
99+
echo "Initializing BuildTools..."
100+
echo "Running: $__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR" >> $__init_tools_log
109101

110-
sed -i -e "s/2.0.0-preview1-001913-00/2.0.0/g" "$__TOOLRUNTIME_DIR/MSBuild.runtimeconfig.json"
111-
fi
102+
# Executables restored with .NET Core 2.0 do not have executable permission flags. https://github.com/NuGet/Home/issues/4424
103+
chmod +x $__BUILD_TOOLS_PATH/init-tools.sh
104+
$__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR >> $__init_tools_log
105+
if [ "$?" != "0" ]; then
106+
echo "ERROR: An error occured when trying to initialize the tools. Please check '$__init_tools_log' for more details."1>&2
107+
exit 1
108+
fi
112109

113-
echo "Making all .sh files executable under Tools."
114-
# Executables restored with .NET Core 2.0 do not have executable permission flags. https://github.com/NuGet/Home/issues/4424
115-
ls $__scriptpath/Tools/*.sh | xargs chmod +x
116-
ls $__scriptpath/Tools/scripts/docker/*.sh | xargs chmod +x
110+
echo "Making all .sh files executable under Tools."
111+
# Executables restored with .NET Core 2.0 do not have executable permission flags. https://github.com/NuGet/Home/issues/4424
112+
ls $__scriptpath/Tools/*.sh | xargs chmod +x
113+
ls $__scriptpath/Tools/scripts/docker/*.sh | xargs chmod +x
117114

118-
Tools/crossgen.sh $__scriptpath/Tools
115+
Tools/crossgen.sh $__scriptpath/Tools
119116

120-
mkdir -p $__INIT_TOOLS_DONE_MARKER_DIR
121-
touch $__INIT_TOOLS_DONE_MARKER
117+
mkdir -p "$(dirname "$__BUILD_TOOLS_SEMAPHORE")" && touch $__BUILD_TOOLS_SEMAPHORE
118+
119+
echo "Done initializing tools."
122120

123-
echo "Done initializing tools."
124-
else
125-
echo "Tools are already initialized"
126-
fi

0 commit comments

Comments
 (0)