-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add basic ability to get latest version and install to installation library #51374
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
Changes from all commits
be9bae3
6c9b582
eb6e2af
c2b7688
585e48e
42c9a4b
7614f22
f5a52ed
9bd5bb0
171854b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Text; | ||
|
|
||
| [assembly: InternalsVisibleTo("dnup, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] | ||
| [assembly: InternalsVisibleTo("dnup.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Text; | ||
| using Microsoft.Dotnet.Installation.Internal; | ||
|
|
||
| namespace Microsoft.Dotnet.Installation; | ||
|
|
||
| public static class InstallerFactory | ||
| { | ||
| public static IDotnetInstaller CreateInstaller() | ||
nagilson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| return new DotnetInstaller(); | ||
| } | ||
|
|
||
| public static IDotnetReleaseInfoProvider CreateReleaseInfoProvider() | ||
| { | ||
| return new DotnetReleaseInfoProvider(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Runtime.InteropServices; | ||
| using System.Text; | ||
|
|
||
| namespace Microsoft.Dotnet.Installation; | ||
|
|
||
| public static class InstallerUtilities | ||
| { | ||
| public static InstallArchitecture GetInstallArchitecture(System.Runtime.InteropServices.Architecture architecture) | ||
| { | ||
| return architecture switch | ||
| { | ||
| System.Runtime.InteropServices.Architecture.X86 => InstallArchitecture.x86, | ||
| System.Runtime.InteropServices.Architecture.X64 => InstallArchitecture.x64, | ||
| System.Runtime.InteropServices.Architecture.Arm64 => InstallArchitecture.arm64, | ||
| _ => throw new NotSupportedException($"Architecture {architecture} is not supported.") | ||
| }; | ||
| } | ||
|
|
||
| public static InstallArchitecture GetDefaultInstallArchitecture() | ||
| { | ||
| return GetInstallArchitecture(RuntimeInformation.ProcessArchitecture); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,17 +10,17 @@ | |
| using System.Runtime.InteropServices; | ||
| using Microsoft.Deployment.DotNet.Releases; | ||
|
|
||
| namespace Microsoft.DotNet.Tools.Bootstrapper; | ||
| namespace Microsoft.Dotnet.Installation.Internal; | ||
|
|
||
| internal class ArchiveDotnetInstaller : IDotnetInstaller, IDisposable | ||
| internal class ArchiveDotnetExtractor : IDisposable | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about the name DotnetArchiveExtractor? It feels more consistent with other types like DotnetInstaller. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this name! Agree it's an improvement. |
||
| { | ||
| private readonly DotnetInstallRequest _request; | ||
| private readonly ReleaseVersion _resolvedVersion; | ||
| private readonly bool _noProgress; | ||
| private string scratchDownloadDirectory; | ||
| private string? _archivePath; | ||
|
|
||
| public ArchiveDotnetInstaller(DotnetInstallRequest request, ReleaseVersion resolvedVersion, bool noProgress = false) | ||
| public ArchiveDotnetExtractor(DotnetInstallRequest request, ReleaseVersion resolvedVersion, bool noProgress = false) | ||
| { | ||
| _request = request; | ||
| _resolvedVersion = resolvedVersion; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Text; | ||
| using Microsoft.Deployment.DotNet.Releases; | ||
| using Spectre.Console; | ||
|
|
||
| namespace Microsoft.Dotnet.Installation.Internal | ||
| { | ||
| internal class DotnetInstaller : IDotnetInstaller | ||
| { | ||
| public void Install(DotnetInstallRoot dotnetRoot, InstallComponent component, ReleaseVersion version) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: DotnetInstaller and DotnetReleaseInfoProvider have brank lines between the members. |
||
| { | ||
| var installRequest = new DotnetInstallRequest(dotnetRoot, new UpdateChannel(version.ToString()), component, new InstallRequestOptions()); | ||
|
|
||
| using ArchiveDotnetExtractor installer = new(installRequest, version, noProgress: true); | ||
| installer.Prepare(); | ||
| installer.Commit(); | ||
| } | ||
| public void Uninstall(DotnetInstallRoot dotnetRoot, InstallComponent component, ReleaseVersion version) => throw new NotImplementedException(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Text; | ||
| using Microsoft.Deployment.DotNet.Releases; | ||
|
|
||
| namespace Microsoft.Dotnet.Installation.Internal; | ||
|
|
||
| internal class DotnetReleaseInfoProvider : IDotnetReleaseInfoProvider | ||
| { | ||
| public IEnumerable<string> GetAvailableChannels() => throw new NotImplementedException(); | ||
| public ReleaseVersion? GetLatestVersion(InstallComponent component, string channel) | ||
| { | ||
| var releaseManifest = new ReleaseManifest(); | ||
| var release = releaseManifest.GetLatestVersionForChannel(new UpdateChannel(channel), component); | ||
|
|
||
| return release; | ||
| } | ||
| public SupportType GetSupportType(InstallComponent component, ReleaseVersion version) => throw new NotImplementedException(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Text; | ||
| using Microsoft.Deployment.DotNet.Releases; | ||
|
|
||
| namespace Microsoft.Dotnet.Installation.Internal; | ||
|
|
||
| internal class UpdateChannel | ||
| { | ||
| public string Name { get; set; } | ||
|
|
||
| public UpdateChannel(string name) | ||
| { | ||
| Name = name; | ||
| } | ||
|
|
||
| public bool IsFullySpecifiedVersion() | ||
| { | ||
| return ReleaseVersion.TryParse(Name, out _); | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It might be better to fail if we can't find a release version - that would likely be cleaner than requiring invokers to use
!. What do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As is, the caller should probably check for a null return value and either throw an error or handle appropriately if there is one. It might be better to just throw in the implementation. I think we'll want to clean up a lot of the
ReleaseManifestcode, probably we can consider when we do that.