Skip to content

Conversation

@edvilme
Copy link
Contributor

@edvilme edvilme commented Apr 14, 2025

Closes #31103

WIP: Name, and implementation may change

image

@ghost ghost added Area-Tools untriaged Request triage from a team member labels Apr 14, 2025
@marcpopMSFT
Copy link
Member

Commented offline that we wanted to start with "dotnet tool run --from-source". We're currently discussing alias options or auto-detection options but the full command is safest to start with.

@dsplaisted
Copy link
Member

@edvilme I would recommend patterning this more off of local tools than global tools. Global tools download the packages to a folder structure under .dotnet\tools\.store\, and also download it to a staging folder before copying it to the final location. An executable shim is also created or copied to the global tools folder.

Local tools on the other hand run directly from the packages in the NuGet global packages folder. I think it would be easier to run a tool from there without any side effects besides the fact that the package is now in the global packages folder.

@edvilme edvilme changed the title [WIP] tool runx [WIP] dotnet run: --from-source Apr 15, 2025
@edvilme edvilme marked this pull request as ready for review April 15, 2025 04:57
@edvilme edvilme requested review from a team and dsplaisted April 15, 2025 04:57
Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

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

Things to consider for review when it is finished / good test cases:

  • Does it delete the tool, as it says without permanently installing it
  • It passes the args to tools
  • Version resolution works
  • Uses latest if no version specified
  • It uses the feed
  • Make sure we prompt before downloading something new
  • Does it have -y -n
  • Supports nuget feed options

I like dotnet toolx personally but ok to see why we are using --from-source for now since it matches the other patterns.

@edvilme edvilme marked this pull request as draft April 17, 2025 00:15
@edvilme
Copy link
Contributor Author

edvilme commented May 5, 2025

/ba-g stuck

@marcpopMSFT
Copy link
Member

Note: Ready for review, failing some test.

Copy link
Contributor

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

The core functionality here looks good to me, but there are several cleanup things I noticed as I was reviewing. Great work!

};

public static readonly Option<string> VersionOption = ToolInstallCommandParser.VersionOption;
public static readonly Option<bool> RollForwardOption = ToolInstallCommandParser.RollForwardOption;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have to define these here as opposed to just adding ToolInstallCommandParser.RollForwardOption in ToolExecuteCommandParser.ConstructCommand and using that in the Command?

@marcpopMSFT
Copy link
Member

marcpopMSFT commented Jun 6, 2025

I fixed the issues flagged in the PR review from forgind and did some local testing.

Testing done:
Example command: dotnet tool exec dotnetsay --version 2.1.* --source https://api.nuget.org/v3/index.json -- hello from dotnetsay

  • version
  • version with a .*
  • @ version
  • --source
  • --add-source
  • --ignore-failed-sources
  • --yes
  • tool parameters

Testing I haven't done:

  • --configfile
  • --prerelease
  • --interactive
  • --verbosity

I didn't review the code or the automated tests yet.

2 issues identified:

  1. I had to check the package id was null even though System.CommandLine already does (because of nullable enabled) that so currently there is a graceful error that I don't think will ever be hit. Suggestions?
  2. It reports the tool is not found on the system even though it's already in the nuget cache. Need to investigate.

@baronfel
Copy link
Member

baronfel commented Jun 6, 2025

I had to check the package id was null even though System.CommandLine already does (because of nullable enabled) that so currently there is a graceful error that I don't think will ever be hit. Suggestions?

dotnet/command-line-api#2564 went into S.CL last week that you're intended to use for this scenario - kind of a marker that "trust me bro, I know what I'm doing"

<data name="YesOptionDescription" xml:space="preserve">
<value>Overrides confirmation prompt with "yes" value. </value>
</data>
<data name="NoOptionDescription" xml:space="preserve">
Copy link
Contributor

Choose a reason for hiding this comment

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

This still seems unused.

Copy link
Member

Choose a reason for hiding this comment

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

Fixed in follow-up PR: #49329

<data name="ToolRunCommandDescription" xml:space="preserve">
<value>Run a local tool. Note that this command cannot be used to run a global tool. </value>
</data>
<data name="ToolRunArguementsDescription" xml:space="preserve">
Copy link
Contributor

Choose a reason for hiding this comment

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

tiny nit:

Suggested change
<data name="ToolRunArguementsDescription" xml:space="preserve">
<data name="ToolRunArgumentsDescription" xml:space="preserve">

Copy link
Member

Choose a reason for hiding this comment

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

Fixed in follow-up PR: #49329

@dsplaisted
Copy link
Member

dsplaisted commented Jun 10, 2025

I've created a new PR to continue work on this, so I'm going to close this one.

@dsplaisted dsplaisted closed this Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Tools untriaged Request triage from a team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a one-shot execution mode for .NET tools a la npx

6 participants