Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 0181c67

Browse files
author
Peter Huene
committed
Fix validation of tool-path option for tool list and uninstall commands.
This commit checks that the `--tool-path` option for the `tool list` and `tool uninstall` commands is a directory that exists. If the directory does not exist, an error and the command help is displayed. Fixes #8931.
1 parent 4883d96 commit 0181c67

32 files changed

+220
-22
lines changed

src/dotnet/commands/dotnet-tool/list/LocalizableStrings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,7 @@
144144
<data name="CommandsColumn" xml:space="preserve">
145145
<value>Commands</value>
146146
</data>
147+
<data name="InvalidToolPathOption" xml:space="preserve">
148+
<value>Tool path '{0}' does not exist.</value>
149+
</data>
147150
</root>

src/dotnet/commands/dotnet-tool/list/ToolListCommand.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.IO;
67
using System.Linq;
78
using Microsoft.DotNet.Cli;
89
using Microsoft.DotNet.Cli.CommandLine;
@@ -44,6 +45,14 @@ public override int Execute()
4445
DirectoryPath? toolPath = null;
4546
if (!string.IsNullOrWhiteSpace(toolPathOption))
4647
{
48+
if (!Directory.Exists(toolPathOption))
49+
{
50+
throw new GracefulException(
51+
string.Format(
52+
LocalizableStrings.InvalidToolPathOption,
53+
toolPathOption));
54+
}
55+
4756
toolPath = new DirectoryPath(toolPathOption);
4857
}
4958

src/dotnet/commands/dotnet-tool/list/xlf/LocalizableStrings.cs.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<target state="new">(--global) conflicts with the tool path option (--tool-path). Please specify only one of the options.</target>
4848
<note />
4949
</trans-unit>
50+
<trans-unit id="InvalidToolPathOption">
51+
<source>Tool path '{0}' does not exist.</source>
52+
<target state="new">Tool path '{0}' does not exist.</target>
53+
<note />
54+
</trans-unit>
5055
</body>
5156
</file>
5257
</xliff>

src/dotnet/commands/dotnet-tool/list/xlf/LocalizableStrings.de.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<target state="new">(--global) conflicts with the tool path option (--tool-path). Please specify only one of the options.</target>
4848
<note />
4949
</trans-unit>
50+
<trans-unit id="InvalidToolPathOption">
51+
<source>Tool path '{0}' does not exist.</source>
52+
<target state="new">Tool path '{0}' does not exist.</target>
53+
<note />
54+
</trans-unit>
5055
</body>
5156
</file>
5257
</xliff>

src/dotnet/commands/dotnet-tool/list/xlf/LocalizableStrings.es.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<target state="new">(--global) conflicts with the tool path option (--tool-path). Please specify only one of the options.</target>
4848
<note />
4949
</trans-unit>
50+
<trans-unit id="InvalidToolPathOption">
51+
<source>Tool path '{0}' does not exist.</source>
52+
<target state="new">Tool path '{0}' does not exist.</target>
53+
<note />
54+
</trans-unit>
5055
</body>
5156
</file>
5257
</xliff>

src/dotnet/commands/dotnet-tool/list/xlf/LocalizableStrings.fr.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<target state="new">(--global) conflicts with the tool path option (--tool-path). Please specify only one of the options.</target>
4848
<note />
4949
</trans-unit>
50+
<trans-unit id="InvalidToolPathOption">
51+
<source>Tool path '{0}' does not exist.</source>
52+
<target state="new">Tool path '{0}' does not exist.</target>
53+
<note />
54+
</trans-unit>
5055
</body>
5156
</file>
5257
</xliff>

src/dotnet/commands/dotnet-tool/list/xlf/LocalizableStrings.it.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<target state="new">(--global) conflicts with the tool path option (--tool-path). Please specify only one of the options.</target>
4848
<note />
4949
</trans-unit>
50+
<trans-unit id="InvalidToolPathOption">
51+
<source>Tool path '{0}' does not exist.</source>
52+
<target state="new">Tool path '{0}' does not exist.</target>
53+
<note />
54+
</trans-unit>
5055
</body>
5156
</file>
5257
</xliff>

src/dotnet/commands/dotnet-tool/list/xlf/LocalizableStrings.ja.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<target state="new">(--global) conflicts with the tool path option (--tool-path). Please specify only one of the options.</target>
4848
<note />
4949
</trans-unit>
50+
<trans-unit id="InvalidToolPathOption">
51+
<source>Tool path '{0}' does not exist.</source>
52+
<target state="new">Tool path '{0}' does not exist.</target>
53+
<note />
54+
</trans-unit>
5055
</body>
5156
</file>
5257
</xliff>

src/dotnet/commands/dotnet-tool/list/xlf/LocalizableStrings.ko.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<target state="new">(--global) conflicts with the tool path option (--tool-path). Please specify only one of the options.</target>
4848
<note />
4949
</trans-unit>
50+
<trans-unit id="InvalidToolPathOption">
51+
<source>Tool path '{0}' does not exist.</source>
52+
<target state="new">Tool path '{0}' does not exist.</target>
53+
<note />
54+
</trans-unit>
5055
</body>
5156
</file>
5257
</xliff>

src/dotnet/commands/dotnet-tool/list/xlf/LocalizableStrings.pl.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<target state="new">(--global) conflicts with the tool path option (--tool-path). Please specify only one of the options.</target>
4848
<note />
4949
</trans-unit>
50+
<trans-unit id="InvalidToolPathOption">
51+
<source>Tool path '{0}' does not exist.</source>
52+
<target state="new">Tool path '{0}' does not exist.</target>
53+
<note />
54+
</trans-unit>
5055
</body>
5156
</file>
5257
</xliff>

0 commit comments

Comments
 (0)