Skip to content

dotnet tool install --local works by default, by creating a manifest by default, utilizing --create-manifest-if-needed #48906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6ac6981
Set the default value of Create Manifest If Needed to True
nagilson May 12, 2025
6c059f9
Add test to show it uses manifest if needed by default
nagilson May 12, 2025
9973ff0
Update Tests
nagilson May 12, 2025
ac1eae1
Fix Test
nagilson May 12, 2025
11d59e6
Accept 'false' instead of just empty arity and add 0 arity test
nagilson May 12, 2025
ff21731
Update completions test bash
nagilson May 12, 2025
fbc755f
Merge branch 'main' into nagilson-create-tool-manifest-by-default
nagilson May 12, 2025
99b0d0e
Update snapshots
nagilson May 12, 2025
a3124b9
Merge branch 'nagilson-create-tool-manifest-by-default' of https://gi…
nagilson May 12, 2025
85792ad
Remove `ToolInstallNoManifestGuide` and Fix `CannotFindAManifestFile `
nagilson Jun 2, 2025
878dd64
Update xlf
nagilson Jun 2, 2025
f99aa7d
Merge branch 'main' into nagilson-create-tool-manifest-by-default
nagilson Jun 2, 2025
dff877f
update xlf again
nagilson Jun 3, 2025
ea6a8c1
Remove ListOfSearched
nagilson Jun 4, 2025
fb759dc
Update XLF
nagilson Jun 4, 2025
7c86837
Fix Test
nagilson Jun 4, 2025
e9d6d70
Fix test string format
nagilson Jun 6, 2025
e5823e9
Merge branch 'main' into nagilson-create-tool-manifest-by-default
nagilson Jun 6, 2025
80cf895
Fix variables in restore-toolset.sh/.ps1
akoeplinger Jun 6, 2025
3979190
Merge branch 'main' into nagilson-create-tool-manifest-by-default
nagilson Jun 10, 2025
76fe22d
Fix all of the tests
nagilson Jun 10, 2025
2543536
Merge branch 'main' into nagilson-create-tool-manifest-by-default
nagilson Jun 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/Cli/dotnet/CliStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ The default is 'false.' However, when targeting .NET 7 or lower, the default is
<value>outputpathresolver: {0} does not exist</value>
</data>
<data name="CannotFindAManifestFile" xml:space="preserve">
<value>Cannot find a manifest file.
For a list of locations searched, specify the "-d" option before the tool name.</value>
<value>Cannot find a manifest file. The list of searched paths:
{0}</value>
</data>
<data name="CannotFindPackageIdInManifest" xml:space="preserve">
<value>Cannot find a package with the package id {0} in the manifest file.</value>
Expand Down Expand Up @@ -670,10 +670,6 @@ For a list of locations searched, specify the "-d" option before the tool name.<
<data name="LibraryNotFoundInLockFile" xml:space="preserve">
<value>{0}: library not found in lock file.</value>
</data>
<data name="ListOfSearched" xml:space="preserve">
<value>The list of searched paths:
{0}</value>
</data>
<data name="LookingForPreferCliRuntimeFile" xml:space="preserve">
<value>{0}: Looking for prefercliruntime file at `{1}`</value>
</data>
Expand Down
4 changes: 0 additions & 4 deletions src/Cli/dotnet/Commands/CliCommandStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1975,10 +1975,6 @@ Tool '{1}' (version '{2}') was successfully installed.</value>
<data name="ToolInstallManifestPathOptionName" xml:space="preserve">
<value>PATH</value>
</data>
<data name="ToolInstallNoManifestGuide" xml:space="preserve">
<value>If you intended to install a global tool, add `--global` to the command.
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>
</data>
<data name="ToolInstallNuGetConfigurationFileDoesNotExist" xml:space="preserve">
<value>NuGet configuration file '{0}' does not exist.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ internal static class ToolInstallCommandParser
public static readonly Option<bool> CreateManifestIfNeededOption = new("--create-manifest-if-needed")
{
Description = CliCommandStrings.CreateManifestIfNeededOptionDescription,
Arity = ArgumentArity.Zero
Arity = ArgumentArity.ZeroOrOne,
DefaultValueFactory = _ => true,
};

public static readonly Option<bool> AllowPackageDowngradeOption = new("--allow-downgrade")
Expand Down
16 changes: 3 additions & 13 deletions src/Cli/dotnet/Commands/Tool/Install/ToolInstallLocalCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,8 @@ public int InstallNewTool(FilePath manifestFile, PackageId packageId)

public FilePath GetManifestFilePath()
{
try
{
return string.IsNullOrWhiteSpace(_explicitManifestFile)
? _toolManifestFinder.FindFirst(_createManifestIfNeeded)
: new FilePath(_explicitManifestFile);
}
catch (ToolManifestCannotBeFoundException e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we want this to be graceful?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It throws ToolManifestCannotBeFoundException in findFirst, which is a child class of GracefulException

{
throw new GracefulException(
[e.Message, CliCommandStrings.ToolInstallNoManifestGuide],
verboseMessages: [e.VerboseMessage],
isUserError: false);
}
return string.IsNullOrWhiteSpace(_explicitManifestFile)
? _toolManifestFinder.FindFirst(_createManifestIfNeeded)
: new FilePath(_explicitManifestFile);
}
}
9 changes: 1 addition & 8 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,4 @@ internal class ToolManifestCannotBeFoundException : GracefulException
public ToolManifestCannotBeFoundException(string message) : base([message], null, false)
{
}

public ToolManifestCannotBeFoundException(string message, string optionalMessage)
: base([message], [optionalMessage], false)
{
}
}
17 changes: 3 additions & 14 deletions src/Cli/dotnet/ToolManifest/ToolManifestFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ public IReadOnlyCollection<ToolManifestPackage> Find(FilePath? filePath = null)

if (!findAnyManifest)
{
throw new ToolManifestCannotBeFoundException(
CliStrings.CannotFindAManifestFile,
string.Format(CliStrings.ListOfSearched,
string.Join(Environment.NewLine, allPossibleManifests.Select(f => "\t" + f.manifestfile.Value))));
throw new ToolManifestCannotBeFoundException(string.Format(CliStrings.CannotFindAManifestFile, string.Join(Environment.NewLine, allPossibleManifests.Select(f => "\t" + f.manifestfile.Value))));
}

return [.. toolManifestPackageAndSource.Select(t => t.toolManifestPackage)];
Expand Down Expand Up @@ -182,11 +179,7 @@ public FilePath FindFirst(bool createIfNotFound = false)
return new FilePath(WriteManifestFile(manifestInsertFolder));
}
}
throw new ToolManifestCannotBeFoundException(
CliStrings.CannotFindAManifestFile,
string.Format(CliStrings.ListOfSearched,
string.Join(Environment.NewLine,
EnumerateDefaultAllPossibleManifests().Select(f => "\t" + f.manifestfile.Value))));
throw new ToolManifestCannotBeFoundException(string.Format(CliStrings.CannotFindAManifestFile, string.Join(Environment.NewLine, EnumerateDefaultAllPossibleManifests().Select(f => "\t" + f.manifestfile.Value))));
}

/*
Expand Down Expand Up @@ -274,11 +267,7 @@ in EnumerateDefaultAllPossibleManifests())

if (!findAnyManifest)
{
throw new ToolManifestCannotBeFoundException(
CliStrings.CannotFindAManifestFile,
string.Format(CliStrings.ListOfSearched,
string.Join(Environment.NewLine,
EnumerateDefaultAllPossibleManifests().Select(f => "\t" + f.manifestfile.Value))));
throw new ToolManifestCannotBeFoundException(string.Format(CliStrings.CannotFindAManifestFile, string.Join(Environment.NewLine, EnumerateDefaultAllPossibleManifests().Select(f => "\t" + f.manifestfile.Value))));
}

return result;
Expand Down
Loading
Loading