Skip to content

Commit 1b82fe0

Browse files
committed
Implement GetAvailableChannels
1 parent 11265f1 commit 1b82fe0

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

src/Installer/Microsoft.Dotnet.Installation/Internal/DotnetReleaseInfoProvider.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ namespace Microsoft.Dotnet.Installation.Internal;
1010

1111
internal class DotnetReleaseInfoProvider : IDotnetReleaseInfoProvider
1212
{
13-
public IEnumerable<string> GetAvailableChannels() => throw new NotImplementedException();
13+
public IEnumerable<string> GetAvailableChannels()
14+
{
15+
var releaseManifest = new ReleaseManifest();
16+
return releaseManifest.GetAvailableChannels();
17+
}
1418
public ReleaseVersion? GetLatestVersion(InstallComponent component, string channel)
1519
{
1620
var releaseManifest = new ReleaseManifest();

src/Installer/Microsoft.Dotnet.Installation/Internal/ReleaseManifest.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ internal class ReleaseManifest(HttpClient httpClient) : IDisposable
5353
return (major, minor, featureBand, isFullySpecified);
5454
}
5555

56+
public IEnumerable<string> GetAvailableChannels()
57+
{
58+
59+
return ["latest", "preview", "lts", "sts",
60+
..GetProductCollection()
61+
.Where(p => p.IsSupported)
62+
.Select(p => p.ProductVersion.ToString())
63+
];
64+
65+
}
66+
5667
/// <summary>
5768
/// Finds the latest fully specified version for a given channel string (major, major.minor, or feature band).
5869
/// </summary>
@@ -64,17 +75,17 @@ internal class ReleaseManifest(HttpClient httpClient) : IDisposable
6475
if (string.Equals(channel.Name, "lts", StringComparison.OrdinalIgnoreCase) || string.Equals(channel.Name, "sts", StringComparison.OrdinalIgnoreCase))
6576
{
6677
var releaseType = string.Equals(channel.Name, "lts", StringComparison.OrdinalIgnoreCase) ? ReleaseType.LTS : ReleaseType.STS;
67-
var productIndex = ProductCollection.GetAsync().GetAwaiter().GetResult();
78+
var productIndex = GetProductCollection();
6879
return GetLatestVersionByReleaseType(productIndex, releaseType, component);
6980
}
7081
else if (string.Equals(channel.Name, "preview", StringComparison.OrdinalIgnoreCase))
7182
{
72-
var productIndex = ProductCollection.GetAsync().GetAwaiter().GetResult();
83+
var productIndex = GetProductCollection();
7384
return GetLatestPreviewVersion(productIndex, component);
7485
}
7586
else if (string.Equals(channel.Name, "latest", StringComparison.OrdinalIgnoreCase))
7687
{
77-
var productIndex = ProductCollection.GetAsync().GetAwaiter().GetResult();
88+
var productIndex = GetProductCollection();
7889
return GetLatestActiveVersion(productIndex, component);
7990
}
8091

@@ -93,7 +104,7 @@ internal class ReleaseManifest(HttpClient httpClient) : IDisposable
93104
}
94105

95106
// Load the index manifest
96-
var index = ProductCollection.GetAsync().GetAwaiter().GetResult();
107+
var index = GetProductCollection();
97108
if (minor < 0)
98109
{
99110
return GetLatestVersionForMajorOrMajorMinor(index, major, component); // Major Only (e.g., "9")

src/Installer/dnup/Commands/Sdk/Install/SdkInstallCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal class SdkInstallCommand(ParseResult result) : CommandBase(result)
2323
private readonly bool _noProgress = result.GetValue(SdkInstallCommandParser.NoProgressOption);
2424

2525
private readonly IDotnetInstallManager _dotnetInstaller = new DotnetInstallManager();
26-
private readonly IDotnetReleaseInfoProvider _releaseInfoProvider = new EnvironmentVariableMockReleaseInfoProvider();
26+
private readonly IDotnetReleaseInfoProvider _releaseInfoProvider = new DotnetReleaseInfoProvider();
2727
private readonly ManifestChannelVersionResolver _channelVersionResolver = new ManifestChannelVersionResolver();
2828

2929
public override int Execute()

0 commit comments

Comments
 (0)