Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Tool/Execute/ToolExecuteCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace Microsoft.DotNet.Cli.Commands.Tool.Execute;

internal sealed class ToolExecuteCommand : CommandBase<ToolExecuteCommandDefinition>
internal sealed class ToolExecuteCommand : CommandBase<ToolExecuteCommandDefinitionBase>
{
const int ERROR_CANCELLED = 1223; // Windows error code for "Operation canceled by user"

Expand Down
26 changes: 20 additions & 6 deletions test/Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,10 @@ public void PackageToolWithAnyRid()
.And.Satisfy<string>(SupportAllOfTheseRuntimes([.. expectedRids, "any"]));
}

[Fact]
public void InstallAndRunToolFromAnyRid()
[Theory]
[InlineData("exec")]
[InlineData("dnx")]
public void InstallAndRunToolFromAnyRid(string command)
{
var toolSettings = new TestToolBuilder.TestToolSettings()
{
Expand All @@ -282,16 +284,23 @@ public void InstallAndRunToolFromAnyRid()
var testDirectory = _testAssetsManager.CreateTestDirectory();
var homeFolder = Path.Combine(testDirectory.Path, "home");

new DotnetToolCommand(Log, "exec", toolSettings.ToolPackageId, "--verbosity", "diagnostic", "--yes", "--source", toolPackagesPath)
string[] args = [command, toolSettings.ToolPackageId, "--verbosity", "diagnostic", "--yes", "--source", toolPackagesPath];
var testCommand = command == "dnx"
? new DotnetCommand(Log, args)
: new DotnetToolCommand(Log, args);

testCommand
.WithEnvironmentVariables(homeFolder)
.WithWorkingDirectory(testDirectory.Path)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello Tool!");
}

[Fact]
public void InstallAndRunToolFromAnyRidWhenOtherRidsArePresentButIncompatible()
[Theory]
[InlineData("exec")]
[InlineData("dnx")]
public void InstallAndRunToolFromAnyRidWhenOtherRidsArePresentButIncompatible(string command)
{
var toolSettings = new TestToolBuilder.TestToolSettings()
{
Expand All @@ -310,7 +319,12 @@ .. expectedRids.Select(rid => $"{toolSettings.ToolPackageId}.{rid}.{toolSettings
var testDirectory = _testAssetsManager.CreateTestDirectory();
var homeFolder = Path.Combine(testDirectory.Path, "home");

new DotnetToolCommand(Log, "exec", toolSettings.ToolPackageId, "--verbosity", "diagnostic", "--yes", "--source", toolPackagesPath)
string[] args = [command, toolSettings.ToolPackageId, "--verbosity", "diagnostic", "--yes", "--source", toolPackagesPath];
var testCommand = command == "dnx"
? new DotnetCommand(Log, args)
: new DotnetToolCommand(Log, args);

testCommand
.WithEnvironmentVariables(homeFolder)
.WithWorkingDirectory(testDirectory.Path)
.Execute()
Expand Down
Loading