Skip to content

dotnet tool install doesn't respect isRoot property in manifest #40655

@havranek1024

Description

@havranek1024

Describe the bug

When installing local dotnet tool using dotnet tool install, it will traverse folder structure to see if that tool is already installed in any of parent folders. It will do that even if dotnet-tools.json in current folder has "isRoot": true. However when trying to run the tool, it will not go to a parent folder to look for it and will say that tool is not installed. This behavior is inconsistent and makes using the tool impossible in a subfolder that has it's own manifest file.

To Reproduce

  • Create a folder, for example named main
  • In this folder run dotnet new tool-manifest
  • Still in the same folder run dotnet tool install dotnetsay
  • Create a subfolder in main - let's call it sub
  • In the sub folder run dotnet new tool-manifest
  • Still in the sub folder run dotnet tool install dotnetsay
    • At that point the tool will not be installed in local folder, the SDK will say Tool 'dotnetsay' is up to date (version '2.1.7' manifest file C:\Source\main\.config\dotnet-tools.json)
    • Note that it mentions manifest from a main folder instead of sub
  • Still in sub folder run dotnet tool run dotnetsay
    • SDK will show error Cannot find a tool in the manifest file that has a command named 'dotnetsay'.

Exceptions (if any)

Further technical details

  • The issue is in ToolInstallLocalCommand class
  • The issue has been introduced in 8.0.2 - earlier versions would not look in parent folders to see if the tool is already installed, they would just use first found manifest

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions