8000 [WIP] `dotnet tool exec <package[@version]>` one-shot execution by edvilme · Pull Request #48443 · dotnet/sdk · GitHub
[go: up one dir, main page]

Skip to content

[WIP] dotnet tool exec <package[@version]> one-shot execution #48443

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

Open
wants to merge 40 commits into
base: main
Choose a base branch
from

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 dsplaisted and a team 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 Apr 21, 2025

As per internal discussions, this should be moved to

dotnet tool exec <package[@version]> 

@edvilme edvilme changed the title [WIP] dotnet run: --from-source [WIP] dotnet tool exec <package[@version]> one-shot execution Apr 21, 2025
@edvilme edvilme changed the title [WIP] dotnet tool exec <package[@version]> one-shot execution [WIP] dotnet tool exec <package[@version]>` one-shot execution Apr 21, 2025
@edvilme edvilme changed the title [WIP] dotnet tool exec <package[@version]>` one-shot execution [WIP] dotnet tool exec <package[@version]> one-shot execution Apr 21, 2025
@edvilme edvilme marked this pull request as ready for review April 21, 2025 22:52

VersionRange versionRange = _parseResult.GetVersionRange();

string tempDirectory = PathUtilities.CreateTempSubdirectory();
Copy link
Contributor

Choose a reason for hiding this comment

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

I may just not understand the feature properly, but I thought marcpopMSFT told me that the plan was to execute the tool directly from the nuget cache? Though it would be pretty fast as long as it'd already been downloaded.

@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!

Arity = ArgumentArity.Zero
};

public static Option<bool> NoOption =
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is ever used? And I don't think it should be.

return result.ExitCode;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: some extra blank lines here

@@ -39,6 +42,7 @@ private static Command ConstructCommand()

command.Arguments.Add(CommandNameArgument);
command.Arguments.Add(CommandArgument);

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like you were planning to add one-shot execution to tool run then didn't. Can we revert the changes in this file and move the --yes option to the ToolExecuteCommandParser?

};

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?


public static readonly Argument<IEnumerable<string>> CommandArgument = new("commandArguments")
{
Description = "arguments forwarded to the tool"
Copy link
Contributor

Choose a reason for hiding this comment

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

Localize? And if this is actually expected to be seen by people, might want to rephrase

@@ -2483,6 +2483,12 @@ To display a value, specify the corresponding command-line option without provid
<data name="ZeroTestsRan" xml:space="preserve">
<value>Zero tests ran</value>
</data>
<data name="ToolRunFromSourceOptionDescription" 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.

I don't think this is ever used?


public override int Execute()
{
if (!UserAgreedToRunFromSource() || _packageToolIdentityArgument is null)
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this show up to the user? Just as "Tool exec command returned 1"? If so, we should make that clearer.

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
5 participants
0