-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Respond to dnup feedback from prototype code review
#51446
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
base: release/dnup
Are you sure you want to change the base?
Respond to dnup feedback from prototype code review
#51446
Conversation
Splits up `ReleaseManifest` into 3 pieces: - A. Downloading of .NET Archives - B. Accessing the release manifest & release manifest data structures - C. Parsing a 'channel' into a ReleaseVersion This is a better separation of responsibility and makes each class a far more reasonable size.
What we were doing was setting the AppContext data such that the HOSTFXR_PATH pointed to the installed root location. We don't need to do that, the hostfxr interop(ped) API already points to the dotnet root location within which we want to resolve the hostfxr.
verification should happen in the downloader which will probably be deferred to the release deployment library
dsplaisted
left a comment
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.
Good improvements.
Main issue is that calls into hostfxr no longer work from a NativeAOT app.
|
|
||
| private IEnumerable<Product> GetProductsInMajorOrMajorMinor(IEnumerable<Product> index, int major, int? minor = null) | ||
| { | ||
| var validProducts = index.Where(p => p.ProductVersion.StartsWith(minor is not null ? $"{major}.{minor}" : $"{major}.")); |
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.
Can we do this by checking a version object instead of checking if the string starts with something? I think we'll need to parse the version first but that would seem better to me.
| /// <param name="isLts">True for LTS (Long-Term Support), false for STS (Standard-Term Support)</param> | ||
| /// <param name="mode">InstallComponent.SDK or InstallComponent.Runtime</param> |
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.
Looks like these doc comments are out of date.
| /// <summary> | ||
| /// Handles downloading and parsing .NET release manifests to find the correct installer/archive for a given installation. | ||
| /// </summary> | ||
| internal class DotnetArchiveDownloader(HttpClient httpClient) : IDisposable |
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.
Do we need the constructor that specifies an HttpClient? It doesn't look like we use that outside of the class, and there's no way to specify both an httpClient and a ReleaseManifest.
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.
we will when we want the library vs dnup to use a different custom agent header - or enable customization of timeout(s) for library callers
src/Installer/Microsoft.Dotnet.Installation/Internal/DotnetArchiveDownloader.cs
Show resolved
Hide resolved
| Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)!); | ||
|
|
||
| // Try to get content length for progress reporting | ||
| long? totalBytes = await GetContentLengthAsync(downloadUrl); |
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.
I think this adds an extra HTTP request. Is there a reason to do this separately rather than get the value from the header of the request which actually downloads?
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.
No, this is a great idea.
| var args = DnupTestUtilities.BuildArguments(channel, testEnv.InstallPath, testEnv.ManifestPath); | ||
| (int exitCode, string output) = DnupTestUtilities.RunDnupProcess(args, captureOutput: true, workingDirectory: testEnv.TempRoot); | ||
| exitCode.Should().Be(0, $"dnup exited with code {exitCode}. Output:\n{output}"); |
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: indentation seems wrong here.
| (int exitCode, string firstInstallOutput) = DnupTestUtilities.RunDnupProcess(args, captureOutput: true, workingDirectory: testEnv.TempRoot); | ||
| exitCode.Should().Be(0, $"First installation failed with exit code {exitCode}. Output:\n{firstInstallOutput}"); |
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: indentation
| (exitCode, string output) = DnupTestUtilities.RunDnupProcess(args, captureOutput: true, workingDirectory: testEnv.TempRoot); | ||
| exitCode.Should().Be(0, $"Second installation failed with exit code {exitCode}. Output:\n{output}"); |
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.
Indentation.
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.
Yeah, the test files here are just wrong but also, I was hoping to add the .editorconfig in this PR to enforce format, using statement, etc on save
| using var process = new Process(); | ||
| string repoDotnet = Path.Combine(repoRoot, ".dotnet", DnupUtilities.GetDotnetExeName()); | ||
| process.StartInfo.FileName = File.Exists(repoDotnet) ? repoDotnet : DnupUtilities.GetDotnetExeName(); |
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: indentation
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.
this file seems to be an erroneous revert - in fact, most of the changes to the tests files are wrong.
| process.StartInfo.CreateNoWindow = true; | ||
| process.StartInfo.RedirectStandardOutput = captureOutput; | ||
| process.StartInfo.RedirectStandardError = captureOutput; | ||
| process.StartInfo.WorkingDirectory = workingDirectory ?? Environment.CurrentDirectory; |
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: indentation.
| string programFilesX86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86); | ||
| bool isAdminInstall = installDir.StartsWith(Path.Combine(programFiles, "dotnet"), StringComparison.OrdinalIgnoreCase) || | ||
| installDir.StartsWith(Path.Combine(programFilesX86, "dotnet"), StringComparison.OrdinalIgnoreCase); | ||
| installDir.StartsWith(Path.Combine(programFilesX86, "dotnet"), StringComparison.OrdinalIgnoreCase); // TODO: This should be improved to not be windows-specific |
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.
| installDir.StartsWith(Path.Combine(programFilesX86, "dotnet"), StringComparison.OrdinalIgnoreCase); // TODO: This should be improved to not be windows-specific | |
| installDir.StartsWith(Path.Combine(programFilesX86, "dotnet"), StringComparison.OrdinalIgnoreCase); // TODO: This should be improved to not be windows-specific https://github.com/dotnet/sdk/issues/51601 |
This PR will remediate the issues discussed in #50988 to fix the prototype
dnupcode. It's not a complete review of all of that code, however. I have not reviewed the portion of the CLI and PATH manipulation, though that's not directly part of the library, so I think that will come later.