[release/9.0.1xx-rc2] Fix NullReferenceException for dotnet tool update -g --all
#43516
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Running
dotnet tool update -g -all
would fail starting in 8.0.4xx. A fix is pending for that branch as well which has different code. This is due to aNullReferenceException
-- when calling a delegate function it can return null in the global mode and thus did not check whether the member was null correctly.Customer Impact
For customers upgrading from any .NET version before 8.0.4xx, customers and CI would be broken as well in any scenario that requires updating a global .NET Tool.
Regression
This was an existing behavior in 8.0.4xx where update --all has been totally broken with -g.
Testing
Manual testing has been done to confirm the behavior before and after. A test is not provided due to the nature of the change requiring the store, which is an online component and the issue is not exposable with the mocking code that is currently in place.
Risk
The risk is low; the behavior did not work before. It adds protection against the 'store' or source of places to get .NET tools from being null, which is the expected case with a global tool install.
Backport of #43157 to release/9.0.1xx-rc2
/cc @nagilson @DL444