diff --git a/src/Cli/dotnet/Commands/Tool/Execute/ToolExecuteCommand.cs b/src/Cli/dotnet/Commands/Tool/Execute/ToolExecuteCommand.cs index f9ffad3e94fe..f33175940357 100644 --- a/src/Cli/dotnet/Commands/Tool/Execute/ToolExecuteCommand.cs +++ b/src/Cli/dotnet/Commands/Tool/Execute/ToolExecuteCommand.cs @@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Cli.Commands.Tool.Execute; -internal sealed class ToolExecuteCommand : CommandBase +internal sealed class ToolExecuteCommand : CommandBase { const int ERROR_CANCELLED = 1223; // Windows error code for "Operation canceled by user" diff --git a/test/Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cs b/test/Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cs index 3eae1ab6133e..fdbe9eb07ee2 100644 --- a/test/Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cs +++ b/test/Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cs @@ -266,8 +266,10 @@ public void PackageToolWithAnyRid() .And.Satisfy(SupportAllOfTheseRuntimes([.. expectedRids, "any"])); } - [Fact] - public void InstallAndRunToolFromAnyRid() + [Theory] + [InlineData("exec")] + [InlineData("dnx")] + public void InstallAndRunToolFromAnyRid(string command) { var toolSettings = new TestToolBuilder.TestToolSettings() { @@ -282,7 +284,12 @@ 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() @@ -290,8 +297,10 @@ public void InstallAndRunToolFromAnyRid() .And.HaveStdOutContaining("Hello Tool!"); } - [Fact] - public void InstallAndRunToolFromAnyRidWhenOtherRidsArePresentButIncompatible() + [Theory] + [InlineData("exec")] + [InlineData("dnx")] + public void InstallAndRunToolFromAnyRidWhenOtherRidsArePresentButIncompatible(string command) { var toolSettings = new TestToolBuilder.TestToolSettings() { @@ -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()