Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install .NET SDK from channel if necessary #11791

Merged
merged 1 commit into from
Mar 12, 2025

Conversation

brettfo
Copy link
Contributor

@brettfo brettfo commented Mar 11, 2025

A common practice is for a repo to have a global.json that looks like this:

{
  "sdk": {
    "version": "8.0.0",
    "rollForward": "latestMinor"
  }
}

where the SDK version listed isn't actually a proper SDK version like 8.0.100. The global.json can be used at runtime, however, so we should still try to install what we can.

To accomplish this we see if the SDK version consists of three parts and if the last part is 0 then we can do an alternate installation mechanism where we treat the first two version parts (e.g., 8.0) as an installation channel. We then pass this with a separate switch to the installer script which will install the latest from that channel (e.g., 8.0.404 or whatever is current).

Fixes #11752.

With this change the log looks like this:

updater | Currently installed SDKs: 8.0.404 9.0.101
updater | Installing SDK from channel 9.0
updater | dotnet-install: Attempting to download using primary link https://builds.dotnet.microsoft.com/dotnet/Sdk/9.0.201/dotnet-sdk-9.0.201-linux-x64.tar.gz
updater | dotnet-install: Remote file https://builds.dotnet.microsoft.com/dotnet/Sdk/9.0.201/dotnet-sdk-9.0.201-linux-x64.tar.gz size is 216930685 bytes.
updater | dotnet-install: Extracting archive from https://builds.dotnet.microsoft.com/dotnet/Sdk/9.0.201/dotnet-sdk-9.0.201-linux-x64.tar.gz
updater | dotnet-install: Downloaded file size is 216930685 bytes.
updater | dotnet-install: The remote and local file sizes are equal.
updater | dotnet-install: Installed version is 9.0.201
updater | dotnet-install: Adding to current process PATH: `/usr/local/dotnet/current`. Note: This change will be visible only when sourcing script.
updater | dotnet-install: Note that the script does not resolve dependencies during installation.
updater | dotnet-install: To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install, select your operating system and check the "Dependencies" section.
updater | dotnet-install: Installation finished successfully.
updater | 8.0.404 [/usr/local/dotnet/current/sdk]
updater | 9.0.101 [/usr/local/dotnet/current/sdk]
updater | 9.0.201 [/usr/local/dotnet/current/sdk]

@brettfo brettfo requested a review from a team as a code owner March 11, 2025 22:20
@github-actions github-actions bot added the L: dotnet:nuget NuGet packages via nuget or dotnet label Mar 11, 2025
$versionParts = $sdkVersion.Split(".")
if ($versionParts.Length -eq 3 -and $versionParts[2] -eq "0") {
$channelVersion = "$($versionParts[0]).$($versionParts[1])"
Write-Host "Installind SDK from channel $channelVersion"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: typo on installing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dangit! I just pushed a fix and hoped nobody saw it.

@brettfo brettfo force-pushed the dev/brettfo/nuget-install-sdk-from-channel branch from c3ee722 to 2ef8bb7 Compare March 11, 2025 22:28
@sachin-sandhu sachin-sandhu merged commit 4c4b2be into main Mar 12, 2025
123 checks passed
@sachin-sandhu sachin-sandhu deleted the dev/brettfo/nuget-install-sdk-from-channel branch March 12, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: dotnet:nuget NuGet packages via nuget or dotnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow installing SDK when global.json lists runtime version instead of SDK version
3 participants