dotnetcore-sdk.sh has been refactored for using in both Ubuntu 16/18 deployments

This commit is contained in:
root
2020-02-19 09:56:16 +04:00
committed by Andrey Mishechkin (Akvelon INC)
parent 4d5bdba49c
commit 6da930087b
6 changed files with 22 additions and 141 deletions

50
.vscode/tasks.json vendored
View File

@@ -1,42 +1,14 @@
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${relativeFile}: the current opened file relative to workspaceRoot
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
// Start PowerShell
"windows": {
"command": "${env:windir}/System32/WindowsPowerShell/v1.0/powershell.exe",
//"command": "${env:ProgramFiles}/PowerShell/6.0.0/powershell.exe",
"args": [ "-NoProfile", "-ExecutionPolicy", "Bypass" ]
},
"linux": {
"command": "/usr/bin/powershell",
"args": [ "-NoProfile" ]
},
"osx": {
"command": "/usr/local/bin/powershell",
"args": [ "-NoProfile" ]
},
// Associate with test task runner
"tasks": [
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"taskName": "Test",
"suppressTaskName": true,
"isTestCommand": true,
"args": [
"Write-Host 'Invoking Pester...'; $ProgressPreference = 'SilentlyContinue'; Invoke-Pester -Script test -PesterOption @{IncludeVSCodeMarker=$true};",
"Invoke-Command { Write-Host 'Completed Test task in task runner.' }"
],
"problemMatcher": "$pester"
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (simplest configuration)",
"program": "${file}"
}
]
}
]
}

View File

@@ -9,7 +9,11 @@ LSB_RELEASE=$(lsb_release -rs)
# Install Microsoft repository
wget https://packages.microsoft.com/config/ubuntu/$LSB_RELEASE/packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
apt-get update
apt-get install apt-transport-https
# Install Microsoft GPG public key
curl -L https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list'
apt-get update

View File

@@ -1,99 +0,0 @@
#!/bin/bash
################################################################################
## File: dotnetcore-sdk.sh
## Desc: Installs .NET Core SDK
################################################################################
source $HELPER_SCRIPTS/apt.sh
source $HELPER_SCRIPTS/document.sh
LATEST_DOTNET_PACKAGES=("dotnet-sdk-3.0" "dotnet-sdk-3.1")
LSB_RELEASE=$(lsb_release -rs)
mksamples()
{
sdk=$1
sample=$2
mkdir "$sdk"
cd "$sdk" || exit
set -e
dotnet help
dotnet new globaljson --sdk-version "$sdk"
dotnet new "$sample"
dotnet restore
dotnet build
set +e
cd .. || exit
rm -rf "$sdk"
}
set -e
# Disable telemetry
export DOTNET_CLI_TELEMETRY_OPTOUT=1
for latest_package in ${LATEST_DOTNET_PACKAGES[@]}; do
echo "Determing if .NET Core ($latest_package) is installed"
if ! IsInstalled $latest_package; then
echo "Could not find .NET Core ($latest_package), installing..."
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list'
apt-get install apt-transport-https
apt-get update
apt-get install $latest_package -y
else
echo ".NET Core ($latest_package) is already installed"
fi
done
# Get list of all released SDKs from channels which are not end-of-life or preview
release_urls=("https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/2.1/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/2.2/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/3.0/releases.json" "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/3.1/releases.json")
sdks=()
for release_url in ${release_urls[@]}; do
echo "${release_url}"
releases=$(curl "${release_url}")
sdks=("${sdks[@]}" $(echo "${releases}" | jq '.releases[]' | jq '.sdk.version'))
sdks=("${sdks[@]}" $(echo "${releases}" | jq '.releases[]' | jq '.sdks[]?' | jq '.version'))
done
sortedSdks=$(echo ${sdks[@]} | tr ' ' '\n' | grep -v preview | grep -v rc | grep -v display | cut -d\" -f2 | sort -u -r)
for sdk in $sortedSdks; do
url="https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$sdk/dotnet-sdk-$sdk-linux-x64.tar.gz"
echo "$url" >> urls
echo "Adding $url to list to download later"
done
# Download additional SDKs
echo "Downloading release tarballs..."
cat urls | xargs -n 1 -P 16 wget -q
for tarball in *.tar.gz; do
dest="./tmp-$(basename -s .tar.gz $tarball)"
echo "Extracting $tarball to $dest"
mkdir "$dest" && tar -C "$dest" -xzf "$tarball"
rsync -qav "$dest/shared/" /usr/share/dotnet/shared/
rsync -qav "$dest/host/" /usr/share/dotnet/host/
rsync -qav "$dest/sdk/" /usr/share/dotnet/sdk/
rm -rf "$dest"
rm "$tarball"
done
rm urls
DocumentInstalledItem ".NET Core SDK:"
# Smoke test each SDK
for sdk in $sortedSdks; do
mksamples "$sdk" "console"
mksamples "$sdk" "mstest"
mksamples "$sdk" "xunit"
mksamples "$sdk" "web"
mksamples "$sdk" "mvc"
mksamples "$sdk" "webapi"
DocumentInstalledItemIndent "$sdk"
done
# NuGetFallbackFolder at /usr/share/dotnet/sdk/NuGetFallbackFolder is warmed up by smoke test
# Additional FTE will just copy to ~/.dotnet/NuGet which provides no benefit on a fungible machine
echo "DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1" | tee -a /etc/environment
echo 'export PATH="$PATH:$HOME/.dotnet/tools"' | tee -a /etc/skel/.bashrc

View File

@@ -4,6 +4,7 @@
## Desc: Installs .NET Core SDK
################################################################################
HELPER_SCRIPTS=/repos/virtual-environments/images/linux/scripts/helpers
source $HELPER_SCRIPTS/apt.sh
source $HELPER_SCRIPTS/document.sh
@@ -30,6 +31,9 @@ mksamples()
set -e
# Disable telemetry
export DOTNET_CLI_TELEMETRY_OPTOUT=1
for latest_package in ${LATEST_DOTNET_PACKAGES[@]}; do
echo "Determing if .NET Core ($latest_package) is installed"
if ! IsInstalled $latest_package; then

View File

@@ -131,7 +131,7 @@
"{{template_dir}}/scripts/installers/docker-compose.sh",
"{{template_dir}}/scripts/installers/docker-moby.sh",
"{{template_dir}}/scripts/installers/docker.sh",
"{{template_dir}}/scripts/installers/1604/dotnetcore-sdk.sh",
"{{template_dir}}/scripts/installers/dotnetcore-sdk.sh",
"{{template_dir}}/scripts/installers/erlang.sh",
"{{template_dir}}/scripts/installers/firefox.sh",
"{{template_dir}}/scripts/installers/gcc.sh",

View File

@@ -134,7 +134,7 @@
"{{template_dir}}/scripts/installers/docker-compose.sh",
"{{template_dir}}/scripts/installers/docker-moby.sh",
"{{template_dir}}/scripts/installers/docker.sh",
"{{template_dir}}/scripts/installers/1804/dotnetcore-sdk.sh",
"{{template_dir}}/scripts/installers/dotnetcore-sdk.sh",
"{{template_dir}}/scripts/installers/erlang.sh",
"{{template_dir}}/scripts/installers/firefox.sh",
"{{template_dir}}/scripts/installers/gcc.sh",