Skip to content

Commit ecf792c

Browse files
authored
[release/9.0.1xx-rc2] Fix NullReferenceException for dotnet tool update -g --all (#43516)
2 parents 7163c0a + 5dd9507 commit ecf792c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Diff for: src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallGlobalOrToolPathCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private int ExecuteInstallCommand(PackageId packageId)
159159

160160
if (ToolVersionAlreadyInstalled(oldPackageNullable, nugetVersion))
161161
{
162-
_reporter.WriteLine(string.Format(LocalizableStrings.ToolAlreadyInstalled, _packageId, oldPackageNullable.Version.ToNormalizedString()).Green());
162+
_reporter.WriteLine(string.Format(LocalizableStrings.ToolAlreadyInstalled, oldPackageNullable.Id, oldPackageNullable.Version.ToNormalizedString()).Green());
163163
return 0;
164164
}
165165
}

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)