diff options
author | Steven <steven.liekens@gmail.com> | 2023-09-11 21:16:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-11 21:16:24 +0300 |
commit | 96c1eea40fc97b471ba0b33fcc79273c7ce586c7 (patch) | |
tree | 1ac35df447d38c00cb35e07a7b876dc985fc1329 /test/dotnet/dotnet_helpers.sh | |
parent | 038bed3d58a84885da8a008b80905da17d57a543 (diff) |
Use dotnet-install.sh in .NET feature (#628)feature_dotnet_2.0.0
* Use dotnet-install.sh in .NET feature
* Use latest.version files
* Cleanup runtime args
* Use latest.version files in tests as well
* Improve tests, remove code duplication
* Add stderr helper
* Validate version inputs
* Use suggested description
Co-authored-by: Samruddhi Khandale <samruddhikhandale@github.com>
* Shorter version description
Co-authored-by: Samruddhi Khandale <samruddhikhandale@github.com>
* Shorter version description
Co-authored-by: Samruddhi Khandale <samruddhikhandale@github.com>
* Clean up apt lists
* Verify 7.0 is latest
* Fix PATH, add test for .NET global tools
* Include a copy of dotnet-install.sh in the Feature
* Configure useful env variables
* Use stringly typed booleans
* Keep imperative writing style in option hints
* Update maintainers
Co-authored-by: Samruddhi Khandale <samruddhikhandale@github.com>
* Move dotnet-install.sh into a vendor directory
* Refactor variables
* Amend
* Amend 2
* Use default options from devcontainer-feature.json
* Add back variables
* Fix shellchek warning in fetch_latest_sdk_version
* Inline install_version function
* Fix ShellCheck warnings
* Improve CSV parsing
* Default to latest when configuring an empty version
* Add support for runtime-only configurations
* Move 'none' check higher up
* Deduplicate helper functions, sort into files
* Address the user more directly in NOTES
* Remove unnecessary defaults
* Replace feature -> Feature
Co-authored-by: Samruddhi Khandale <samruddhikhandale@github.com>
* Add update-dotnet-install-script workflow
* Apply suggestions from code review
Co-authored-by: Samruddhi Khandale <samruddhikhandale@github.com>
* Don't skip ci for automated script update
---------
Co-authored-by: Samruddhi Khandale <samruddhikhandale@github.com>
Diffstat (limited to 'test/dotnet/dotnet_helpers.sh')
-rw-r--r-- | test/dotnet/dotnet_helpers.sh | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/test/dotnet/dotnet_helpers.sh b/test/dotnet/dotnet_helpers.sh new file mode 100644 index 0000000..6c833b4 --- /dev/null +++ b/test/dotnet/dotnet_helpers.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# Prints the latest dotnet version in the specified channel +# Usage: fetch_latest_version_in_channel <channel> [<runtime>] +# Example: fetch_latest_version_in_channel "LTS" +# Example: fetch_latest_version_in_channel "6.0" "dotnet" +# Example: fetch_latest_version_in_channel "6.0" "aspnetcore" +fetch_latest_version_in_channel() { + local channel="$1" + local runtime="$2" + if [ "$runtime" = "dotnet" ]; then + wget -qO- "https://dotnetcli.azureedge.net/dotnet/Runtime/$channel/latest.version" + elif [ "$runtime" = "aspnetcore" ]; then + wget -qO- "https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/$channel/latest.version" + else + wget -qO- "https://dotnetcli.azureedge.net/dotnet/Sdk/$channel/latest.version" + fi + +} + +# Prints the latest dotnet version +# Usage: fetch_latest_version [<runtime>] +# Example: fetch_latest_version +# Example: fetch_latest_version "dotnet" +# Example: fetch_latest_version "aspnetcore" +fetch_latest_version() { + local runtime="$1" + local sts_version + local lts_version + sts_version=$(fetch_latest_version_in_channel "STS" "$runtime") + lts_version=$(fetch_latest_version_in_channel "LTS" "$runtime") + if [[ "$sts_version" > "$lts_version" ]]; then + echo "$sts_version" + else + echo "$lts_version" + fi +} + +# Asserts that the specified .NET SDK version is installed +# Returns a non-zero exit code if the check fails +# Usage: is_dotnet_sdk_version_installed <version> +# Example: is_dotnet_sdk_version_installed "6.0" +# Example: is_dotnet_sdk_version_installed "6.0.412" +is_dotnet_sdk_version_installed() { + local expected="$1" + dotnet --list-sdks | grep --fixed-strings --silent "$expected" + return $? +} + + +# Asserts that the specified .NET Runtime version is installed +# Returns a non-zero exit code if the check fails +# Usage: is_dotnet_runtime_version_installed <version> +# Example: is_dotnet_runtime_version_installed "6.0" +# Example: is_dotnet_runtime_version_installed "6.0.412" +is_dotnet_runtime_version_installed() { + local expected="$1" + dotnet --list-runtimes | grep --fixed-strings --silent "Microsoft.NETCore.App $expected" + return $? +} + +# Asserts that the specified ASP.NET Core Runtime version is installed +# Returns a non-zero exit code if the check fails +# Usage: is_aspnetcore_runtime_version_installed <version> +# Example: is_aspnetcore_runtime_version_installed "6.0" +# Example: is_aspnetcore_runtime_version_installed "6.0.412" +is_aspnetcore_runtime_version_installed() { + local expected="$1" + dotnet --list-runtimes | grep --fixed-strings --silent "Microsoft.AspNetCore.App $expected" + return $? +}
\ No newline at end of file |