Skip to content

Commit beb3f36

Browse files
authored
[release/8.0.4xx] Fix NullReferenceException for dotnet tool update -g --all (#43550)
2 parents 0b2b20b + ddf3716 commit beb3f36

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: src/Cli/dotnet/commands/dotnet-tool/update/ToolUpdateCommand.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.DotNet.ToolManifest;
99
using Microsoft.DotNet.ToolPackage;
1010
using Microsoft.DotNet.Tools.Tool.Common;
11+
using Microsoft.Extensions.EnvironmentAbstractions;
1112
using CreateShellShimRepository = Microsoft.DotNet.Tools.Tool.Install.CreateShellShimRepository;
1213

1314
namespace Microsoft.DotNet.Tools.Tool.Update
@@ -43,16 +44,17 @@ public ToolUpdateCommand(
4344
localToolsResolverCache,
4445
reporter);
4546

47+
_global = result.GetValue(ToolInstallCommandParser.GlobalOption);
48+
_toolPath = result.GetValue(ToolInstallCommandParser.ToolPathOption);
49+
DirectoryPath? location = string.IsNullOrWhiteSpace(_toolPath) ? null : new DirectoryPath(_toolPath);
4650
_toolUpdateGlobalOrToolPathCommand =
4751
toolUpdateGlobalOrToolPathCommand
4852
?? new ToolUpdateGlobalOrToolPathCommand(
4953
result,
5054
createToolPackageStoreDownloaderUninstaller,
5155
createShellShimRepository,
52-
reporter);
53-
54-
_global = result.GetValue(ToolInstallCommandParser.GlobalOption);
55-
_toolPath = result.GetValue(ToolInstallCommandParser.ToolPathOption);
56+
reporter,
57+
ToolPackageFactory.CreateToolPackageStoreQuery(location));
5658
}
5759

5860

0 commit comments

Comments
 (0)