Skip to content

Commit a36b14b

Browse files
edvilmedsplaisted
authored andcommitted
Add logic for acquisition and running
1 parent 6ec461c commit a36b14b

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/Cli/dotnet/Commands/Tool/Runx/ToolRunxCommand.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,35 @@ namespace Microsoft.DotNet.Cli.Commands.Tool.Runx;
1414
internal class ToolRunxCommand(ParseResult result) : CommandBase(result)
1515
{
1616
private readonly string _toolCommandName = result.GetValue(ToolRunxCommandParser.CommandNameArgument);
17-
private readonly IEnumerable<string> _forwardArgument = result.GetValue(ToolRunxCommandParser.CommandArgument);
18-
public bool _allowRollForward = result.GetValue(ToolRunxCommandParser.RollForwardOption);
1917

2018
public override int Execute()
2119
{
20+
PackageLocation packageLocation = new PackageLocation();
21+
PackageId packageId = new PackageId(_toolCommandName);
22+
2223
var tempDir = new DirectoryPath(PathUtilities.CreateTempSubdirectory());
23-
return 0;
24+
25+
// Acquire package
26+
27+
ToolPackageStoreAndQuery toolPackageStoreAndQuery = ToolPackageFactory.CreateConcreteToolPackageStore(tempDir);
28+
ToolPackageDownloader toolPackageDownloader = new ToolPackageDownloader(toolPackageStoreAndQuery);
29+
ToolPackageUninstaller toolPackageUninstaller = new ToolPackageUninstaller(toolPackageStoreAndQuery);
30+
31+
IToolPackage toolPackage = toolPackageStoreAndQuery.EnumeratePackageVersions(packageId).FirstOrDefault()
32+
?? toolPackageDownloader.InstallPackage(packageLocation, packageId);
33+
34+
// Run package
35+
36+
DotnetToolsCommandResolver dotnetToolsCommandResolver = new DotnetToolsCommandResolver(toolPackageStoreAndQuery.Root.ToString());
37+
CommandSpec commandSpec = dotnetToolsCommandResolver.Resolve(new CommandResolverArguments()
38+
{
39+
// since LocalToolsCommandResolver is a resolver, and all resolver input have dotnet-
40+
CommandName = $"dotnet-{_toolCommandName}",
41+
CommandArguments = new string[] { },
42+
});
43+
44+
var result = CommandFactoryUsingResolver.Create(commandSpec).Execute();
45+
46+
return result.ExitCode;
2447
}
2548
}

src/Cli/dotnet/Commands/Tool/Runx/ToolRunxCommandParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static CliCommand GetCommand()
3333

3434
private static CliCommand ConstructCommand()
3535
{
36-
CliCommand command = new("run", CliCommandStrings.ToolRunCommandDescription);
36+
CliCommand command = new("runx", "TODO: Run and execute remote tool");
3737

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

0 commit comments

Comments
 (0)