Skip to content

Commit

Permalink
Merge pull request #19 from canonical/fix/latest-lts-first-install
Browse files Browse the repository at this point in the history
Change first run to install latest .NET SDK LTS version
  • Loading branch information
mateusrodrigues authored Nov 27, 2024
2 parents a192462 + 9a3c8a6 commit 378a94d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/Dotnet.Installer.Console/Commands/InstallCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ private async Task Handle(string component, string version)
"latest" => _manifestService.Remote
.Where(c => c.Name.Equals(component, StringComparison.CurrentCultureIgnoreCase))
.MaxBy(c => c.MajorVersion),
"lts" => _manifestService.Remote
.Where(c => c.IsLts && c.Name.Equals(component, StringComparison.CurrentCultureIgnoreCase))
.MaxBy(c => c.MajorVersion),
_ => _manifestService.MatchVersion(component, version)
};

Expand Down
5 changes: 2 additions & 3 deletions src/Dotnet.Installer.Console/Scripts/dotnet-launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ if [[ $# -gt 0 && $1 = "installer" ]]; then
else
# Check for installed .NET components
manifest_path="$SNAP_COMMON/snap/manifest.json"
manifest_data=$(< "$manifest_path")

if [[ $(echo "$manifest_data" | "$SNAP"/usr/bin/jq 'length') -eq 0 ]]; then
if [[ $("$SNAP"/usr/bin/jq 'length' "$manifest_path") -eq 0 ]]; then
echo "Looks like you don't yet have a .NET SDK or Runtime installed."
echo "I am downloading and installing the latest SDK for you to use. It should only be a few moments."

command_to_execute=("$SNAP/Dotnet.Installer.Console" "install" "sdk" "latest")
command_to_execute=("$SNAP/Dotnet.Installer.Console" "install" "sdk" "lts")

if ! run_elevated "0" "${command_to_execute[@]}"; then
echo "Could not install the latest .NET SDK. Please check your credentials or run this command with sudo."
Expand Down

0 comments on commit 378a94d

Please sign in to comment.