Skip to content

Commit 85792ad

Browse files
committed
Remove ToolInstallNoManifestGuide and Fix CannotFindAManifestFile
`CannotFindAManifestFile` now always provides the list of searched locations. Remove the string that is now longer needed now that --create-manifest-if-needed is added by default. Need to look into `ToolCommonNoManifestGuide` and if we still need that
1 parent a3124b9 commit 85792ad

File tree

7 files changed

+12
-47
lines changed

7 files changed

+12
-47
lines changed

src/Cli/dotnet/CliStrings.resx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,7 @@ The default is 'false.' However, when targeting .NET 7 or lower, the default is
568568
<value>outputpathresolver: {0} does not exist</value>
569569
</data>
570570
<data name="CannotFindAManifestFile" xml:space="preserve">
571-
<value>Cannot find a manifest file.
572-
For a list of locations searched, specify the "-d" option before the tool name.</value>
571+
<value>Cannot find a manifest file.</value>
573572
</data>
574573
<data name="CannotFindPackageIdInManifest" xml:space="preserve">
575574
<value>Cannot find a package with the package id {0} in the manifest file.</value>

src/Cli/dotnet/Commands/CliCommandStrings.resx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,10 +1985,6 @@ Tool '{1}' (version '{2}') was successfully installed.</value>
19851985
<data name="ToolInstallManifestPathOptionName" xml:space="preserve">
19861986
<value>PATH</value>
19871987
</data>
1988-
<data name="ToolInstallNoManifestGuide" xml:space="preserve">
1989-
<value>If you intended to install a global tool, add `--global` to the command.
1990-
If you would like to create a manifest, use the `--create-manifest-if-needed` flag with the `dotnet tool install` command, or use `dotnet new tool-manifest`, usually in the repo root directory.</value>
1991-
</data>
19921988
<data name="ToolInstallNuGetConfigurationFileDoesNotExist" xml:space="preserve">
19931989
<value>NuGet configuration file '{0}' does not exist.</value>
19941990
</data>
@@ -2486,4 +2482,4 @@ To display a value, specify the corresponding command-line option without provid
24862482
<data name="SolutionAddReferencedProjectsOptionDescription" xml:space="preserve">
24872483
<value>Recursively add projects' ReferencedProjects to solution</value>
24882484
</data>
2489-
</root>
2485+
</root>

src/Cli/dotnet/Commands/Tool/Install/ToolInstallLocalCommand.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,8 @@ public int InstallNewTool(FilePath manifestFile, PackageId packageId)
194194

195195
public FilePath GetManifestFilePath()
196196
{
197-
try
198-
{
199-
return string.IsNullOrWhiteSpace(_explicitManifestFile)
200-
? _toolManifestFinder.FindFirst(_createManifestIfNeeded)
201-
: new FilePath(_explicitManifestFile);
202-
}
203-
catch (ToolManifestCannotBeFoundException e)
204-
{
205-
throw new GracefulException(
206-
[e.Message, CliCommandStrings.ToolInstallNoManifestGuide],
207-
verboseMessages: [e.VerboseMessage],
208-
isUserError: false);
209-
}
197+
return string.IsNullOrWhiteSpace(_explicitManifestFile)
198+
? _toolManifestFinder.FindFirst(_createManifestIfNeeded)
199+
: new FilePath(_explicitManifestFile);
210200
}
211201
}

src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf

Lines changed: 1 addition & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/ToolManifest/ToolManifestCannotBeFoundException.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,4 @@ internal class ToolManifestCannotBeFoundException : GracefulException
1212
public ToolManifestCannotBeFoundException(string message) : base([message], null, false)
1313
{
1414
}
15-
16-
public ToolManifestCannotBeFoundException(string message, string optionalMessage)
17-
: base([message], [optionalMessage], false)
18-
{
19-
}
2015
}

src/Cli/dotnet/ToolManifest/ToolManifestFinder.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ public IReadOnlyCollection<ToolManifestPackage> Find(FilePath? filePath = null)
4242
if (!findAnyManifest)
4343
{
4444
throw new ToolManifestCannotBeFoundException(
45-
CliStrings.CannotFindAManifestFile,
46-
string.Format(CliStrings.ListOfSearched,
47-
string.Join(Environment.NewLine, allPossibleManifests.Select(f => "\t" + f.manifestfile.Value))));
45+
$@"{CliStrings.CannotFindAManifestFile},
46+
{string.Format(CliStrings.ListOfSearched, string.Join(Environment.NewLine, allPossibleManifests.Select(f => "\t" + f.manifestfile.Value)))}");
4847
}
4948

5049
return [.. toolManifestPackageAndSource.Select(t => t.toolManifestPackage)];
@@ -183,10 +182,8 @@ public FilePath FindFirst(bool createIfNotFound = false)
183182
}
184183
}
185184
throw new ToolManifestCannotBeFoundException(
186-
CliStrings.CannotFindAManifestFile,
187-
string.Format(CliStrings.ListOfSearched,
188-
string.Join(Environment.NewLine,
189-
EnumerateDefaultAllPossibleManifests().Select(f => "\t" + f.manifestfile.Value))));
185+
$@"{CliStrings.CannotFindAManifestFile},
186+
{string.Format(CliStrings.ListOfSearched, string.Join(Environment.NewLine, EnumerateDefaultAllPossibleManifests().Select(f => "\t" + f.manifestfile.Value)))}");
190187
}
191188

192189
/*
@@ -275,10 +272,8 @@ in EnumerateDefaultAllPossibleManifests())
275272
if (!findAnyManifest)
276273
{
277274
throw new ToolManifestCannotBeFoundException(
278-
CliStrings.CannotFindAManifestFile,
279-
string.Format(CliStrings.ListOfSearched,
280-
string.Join(Environment.NewLine,
281-
EnumerateDefaultAllPossibleManifests().Select(f => "\t" + f.manifestfile.Value))));
275+
$@"{CliStrings.CannotFindAManifestFile}
276+
{string.Format(CliStrings.ListOfSearched, string.Join(Environment.NewLine, EnumerateDefaultAllPossibleManifests().Select(f => "\t" + f.manifestfile.Value)))}");
282277
}
283278

284279
return result;

test/dotnet.Tests/CommandTests/Tool/Install/ToolInstallLocalCommandTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ public void GivenNoManifestFileItShouldThrowAndContainNoManifestGuide()
165165
_reporter);
166166

167167
Action a = () => toolInstallLocalCommand.Execute();
168-
a.Should().Throw<GracefulException>()
169-
.And.Message.Should()
170-
.Contain(CliCommandStrings.ToolInstallNoManifestGuide);
171168

172169
a.Should().Throw<GracefulException>()
173170
.And.Message.Should()

0 commit comments

Comments
 (0)