Merge pull request #2041 from krwq/local_sdk_version_detection
install scripts, detect if sdk already installed
This commit is contained in:
commit
cd35ba2a1a
2 changed files with 44 additions and 5 deletions
|
@ -61,7 +61,6 @@ Set-StrictMode -Version Latest
|
|||
$ErrorActionPreference="Stop"
|
||||
$ProgressPreference="SilentlyContinue"
|
||||
|
||||
$LocalVersionFileRelativePath="\.version"
|
||||
$BinFolderRelativePath=""
|
||||
|
||||
# example path with regex: shared/1.0.0-beta-12345/somepath
|
||||
|
@ -184,11 +183,10 @@ function Resolve-Installation-Path([string]$InstallDir) {
|
|||
return $InstallDir
|
||||
}
|
||||
|
||||
# TODO: check for global.json
|
||||
function Get-Installed-Version-Info([string]$InstallRoot) {
|
||||
function Get-Version-Info-From-Version-File([string]$InstallRoot, [string]$RelativePathToVersionFile) {
|
||||
Say-Invocation $MyInvocation
|
||||
|
||||
$VersionFile = Join-Path -Path $InstallRoot -ChildPath $LocalVersionFileRelativePath
|
||||
$VersionFile = Join-Path -Path $InstallRoot -ChildPath $RelativePathToVersionFile
|
||||
Say-Verbose "Local version file: $VersionFile"
|
||||
|
||||
if (Test-Path $VersionFile) {
|
||||
|
@ -202,6 +200,14 @@ function Get-Installed-Version-Info([string]$InstallRoot) {
|
|||
return $null
|
||||
}
|
||||
|
||||
function Is-Dotnet-Package-Installed([string]$InstallRoot, [string]$RelativePathToPackage, [string]$SpecificVersion) {
|
||||
Say-Invocation $MyInvocation
|
||||
|
||||
$DotnetPackagePath = Join-Path -Path $InstallRoot -ChildPath $RelativePathToPackage | Join-Path -ChildPath $SpecificVersion
|
||||
Say-Verbose "Is-Dotnet-Package-Installed: Path to a package: $DotnetPackagePath"
|
||||
return Test-Path $DotnetPackagePath -PathType Container
|
||||
}
|
||||
|
||||
function Get-Absolute-Path([string]$RelativeOrAbsolutePath) {
|
||||
# Too much spam
|
||||
# Say-Invocation $MyInvocation
|
||||
|
@ -300,6 +306,13 @@ if ($DryRun) {
|
|||
$InstallRoot = Resolve-Installation-Path $InstallDir
|
||||
Say-Verbose "InstallRoot: $InstallRoot"
|
||||
|
||||
$IsSdkInstalled = Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage "sdk" -SpecificVersion $SpecificVersion
|
||||
Say-Verbose ".NET SDK installed? $IsSdkInstalled"
|
||||
if ($IsSdkInstalled) {
|
||||
Say ".NET SDK version $SpecificVersion is already installed."
|
||||
return
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $InstallRoot | Out-Null
|
||||
|
||||
foreach ($DownloadLink in $DownloadLinks) {
|
||||
|
|
|
@ -236,6 +236,27 @@ get_commit_hash_from_version_info() {
|
|||
return 0
|
||||
}
|
||||
|
||||
# args:
|
||||
# install_root - $1
|
||||
# relative_path_to_package - $2
|
||||
# specific_version - $3
|
||||
is_dotnet_package_installed() {
|
||||
eval $invocation
|
||||
|
||||
local install_root=$1
|
||||
local relative_path_to_package=$2
|
||||
local specific_version=$3
|
||||
|
||||
local dotnet_package_path=$(combine_paths $(combine_paths $install_root $relative_path_to_package) $specific_version)
|
||||
say_verbose "is_dotnet_package_installed: dotnet_package_path=$dotnet_package_path"
|
||||
|
||||
if [ -d "$dotnet_package_path" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# args:
|
||||
# azure_feed - $1
|
||||
# azure_channel - $2
|
||||
|
@ -483,7 +504,12 @@ calculate_vars() {
|
|||
|
||||
install_dotnet() {
|
||||
eval $invocation
|
||||
|
||||
|
||||
if is_dotnet_package_installed $install_root "sdk" $specific_version; then
|
||||
say ".NET SDK version $specific_version is already installed."
|
||||
return 0
|
||||
fi
|
||||
|
||||
mkdir -p $install_root
|
||||
zip_path=$(mktemp $temporary_file_template)
|
||||
say_verbose "Zip path: $zip_path"
|
||||
|
|
Loading…
Reference in a new issue