diff --git a/scripts/obtain/dotnet-install.ps1 b/scripts/obtain/dotnet-install.ps1 index 1a35ec4fb..5bfd355eb 100644 --- a/scripts/obtain/dotnet-install.ps1 +++ b/scripts/obtain/dotnet-install.ps1 @@ -522,6 +522,7 @@ else { throw "Invalid value for `$Runtime" } +# Check if the SDK version is already installed. $isAssetInstalled = Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage $dotnetPackageRelativePath -SpecificVersion $SpecificVersion if ($isAssetInstalled) { Say "$assetName version $SpecificVersion is already installed." @@ -561,6 +562,12 @@ catch { Say "Extracting zip from $DownloadLink" Extract-Dotnet-Package -ZipPath $ZipPath -OutPath $InstallRoot +# Check if the SDK version is now installed; if not, fail the installation. +$isAssetInstalled = Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage $dotnetPackageRelativePath -SpecificVersion $SpecificVersion +if (!$isAssetInstalled) { + throw "$assetName version $SpecificVersion failed to install with an unknown error." +} + Remove-Item $ZipPath Prepend-Sdk-InstallRoot-To-Path -InstallRoot $InstallRoot -BinFolderRelativePath $BinFolderRelativePath diff --git a/scripts/obtain/dotnet-install.sh b/scripts/obtain/dotnet-install.sh index 27443c397..588d32814 100755 --- a/scripts/obtain/dotnet-install.sh +++ b/scripts/obtain/dotnet-install.sh @@ -754,6 +754,7 @@ install_dotnet() { return 1 fi + # Check if the SDK version is already installed. if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$specific_version"; then say "$asset_name version $specific_version is already installed." return 0 @@ -791,6 +792,12 @@ install_dotnet() { say "Extracting zip from $download_link" extract_dotnet_package "$zip_path" "$install_root" + # Check if the SDK version is now installed; if not, fail the installation. + if ! is_dotnet_package_installed "$install_root" "$asset_relative_path" "$specific_version"; then + say_err "$asset_name version $specific_version failed to install with an unknown error." + return 1 + fi + return 0 }