(#3228) Process .Net 4.8 installation earlier in program execution#3789
(#3228) Process .Net 4.8 installation earlier in program execution#3789corbob wants to merge 2 commits intochocolatey:developfrom
Conversation
|
For our future selves: When I said "where I think this is happening (or at least relatively close)" in #3228, what I mean by the relatively close part is that if I set the .Net registry key such that Chocolatey CLI will fail with this error, Visual Studio will not load properly, and so debugging is not really feasible. However: the logs all encounter this error during the container registration, so the change I made is to verify the .Net version before container registration. One side effect of this is that termination of the program occurs before Chocolatey outputs it's version information, however given that the alternative is for it to terminate before Chocolatey outputs it's version information with an altogether entirely unhelpful error, this seems like a happy middle ground. |
ef20ab5 to
c54f0b1
Compare
c54f0b1 to
67bcab5
Compare
vexx32
left a comment
There was a problem hiding this comment.
I think I'm pretty happy with these changes overall. Will have to see how test runs go but on the whole this approach looks like a good way to go here.
There are instances where .Net is not installed in a way that allows Chocolatey CLI to function. In these scenarios, the version in the registry seems to be very old. This commit accounts for this by wrapping the container registration in a try cath, and displaying a descriptive error in that case. Additionally, this changes the check to use Registry64 instead of Registry32, as on 64 bit systems the 64 bit registry is the one that determines the .Net version. And the lookup on 32 bit systems gracefully falls back to the 32 bit registry.
This updates the .Net version Pester test to use the 64 bit registry as that is the one that Chocolatey CLI is using. Further, it adds a test for the .Net version to be a low integer instead of deleting it. It's been found in some scenarios where the version is there but low .Net misbehaves. It also adds a retry onto taking ownership of the registry key as we've seen instances where it fails to take the ownership and so the test fails. This retry should hopefully resolve these sporadic failures.
67bcab5 to
e0f893e
Compare
I mixed up the version from the config, so a number of the tests failed. I've updated the description with the latest Test Kitchen runs. |
Description Of Changes
Update the check for .Net version to happen before the container is initialized.
Motivation and Context
If .Net is sufficiently old, the container initialization fails and does not provide helpful context.
Testing
Operating Systems Testing
Change Types Made
Change Checklist
Related Issue
Fixes #3228
Reason for Draft
I am still validating the Test Kitchen tests, and working on if others should be added.