From b757854508972f090ee3abb9e7edc8a2c23a1a68 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Tue, 20 Nov 2018 18:06:07 -0800 Subject: [PATCH] Delete "Dependency Tool Invoker" test This is a scenario that is no longer valid, using the Microsoft.DotNet.Cli.Utils library in a project tool to invoke another project tool. It was breaking because the dependency-tool-invoker was using a different version of MSBuild than the CLI, which caused problems when the ToolsVersion changed from 15.0 to Current. --- .../AppliedOptionsExtensions.cs | 30 ----- .../DotnetDependencyToolInvokerParser.cs | 57 --------- .../dotnet-dependency-tool-invoker/Program.cs | 110 ------------------ .../dotnet-dependency-tool-invoker.csproj | 16 --- .../TestAppWithProjDepTool/Program.cs | 15 --- .../TestAppWithProjDepTool.csproj | 18 --- test/EndToEnd/ProjectToolsTests.cs | 44 +------ 7 files changed, 1 insertion(+), 289 deletions(-) delete mode 100644 TestAssets/TestPackages/dotnet-dependency-tool-invoker/AppliedOptionsExtensions.cs delete mode 100644 TestAssets/TestPackages/dotnet-dependency-tool-invoker/DotnetDependencyToolInvokerParser.cs delete mode 100644 TestAssets/TestPackages/dotnet-dependency-tool-invoker/Program.cs delete mode 100644 TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj delete mode 100644 TestAssets/TestProjects/TestAppWithProjDepTool/Program.cs delete mode 100644 TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj diff --git a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/AppliedOptionsExtensions.cs b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/AppliedOptionsExtensions.cs deleted file mode 100644 index a5e32d1ad..000000000 --- a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/AppliedOptionsExtensions.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Linq; -using Microsoft.DotNet.Cli.CommandLine; - -namespace Microsoft.DotNet.Tools.DependencyInvoker -{ - public static class AppliedOptionExtensions - { - public static T ValueOrDefault(this AppliedOption parseResult, string alias) - { - return parseResult - .AppliedOptions - .Where(o => o.HasAlias(alias)) - .Select(o => o.Value()) - .SingleOrDefault(); - } - - public static string SingleArgumentOrDefault(this AppliedOption parseResult, string alias) - { - return parseResult - .AppliedOptions - .Where(o => o.HasAlias(alias)) - .Select(o => o.Arguments.Single()) - .SingleOrDefault(); - } - } -} diff --git a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/DotnetDependencyToolInvokerParser.cs b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/DotnetDependencyToolInvokerParser.cs deleted file mode 100644 index 7c5f1090e..000000000 --- a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/DotnetDependencyToolInvokerParser.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.IO; -using System.Linq; -using Microsoft.DotNet.Cli.CommandLine; -using Microsoft.DotNet.Tools.Common; -using Microsoft.DotNet.Cli.Utils; -using NuGet.Frameworks; - -namespace Microsoft.DotNet.Tools.DependencyInvoker -{ - internal static class DotnetDependencyToolInvokerParser - { - public static Microsoft.DotNet.Cli.CommandLine.Command DotnetDependencyToolInvoker() => - Create.Command( - "dotnet-dependency-tool-invoker", - "DotNet Dependency Tool Invoker", - Accept.ExactlyOneArgument() - .With(name: "COMMAND", - description: "The command to execute."), - false, - Create.Option( - "-h|--help", - "Show help information", - Accept.NoArguments()), - Create.Option( - "-p|--project-path", - "Path to Project.json that contains the tool dependency", - Accept.ExactlyOneArgument() - .With(name: "PROJECT_JSON_PATH", - defaultValue: () => - PathUtility.EnsureTrailingSlash(Directory.GetCurrentDirectory()))), - Create.Option( - "-c|--configuration", - "Configuration under which to build", - Accept.ExactlyOneArgument() - .With(name: "CONFIGURATION", - defaultValue: () => Constants.DefaultConfiguration)), - Create.Option( - "-o|--output", - "Directory in which to find the binaries to be run", - Accept.ExactlyOneArgument() - .With(name: "OUTPUT_DIR")), - Create.Option( - "-f|--framework", - "Looks for test binaries for a specific framework", - Accept.ExactlyOneArgument() - .With(name: "FRAMEWORK") - .MaterializeAs(p => NuGetFramework.Parse(p.Arguments.Single()))), - Create.Option( - "-r|--runtime", - "Look for test binaries for a for the specified runtime", - Accept.ExactlyOneArgument() - .With(name: "RUNTIME_IDENTIFIER"))); - } -} diff --git a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/Program.cs b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/Program.cs deleted file mode 100644 index ff312149e..000000000 --- a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/Program.cs +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.IO; -using System.Collections.Generic; -using System.Linq; -using Microsoft.DotNet.Cli.CommandLine; -using Microsoft.DotNet.Cli.Utils; -using NuGet.Frameworks; -using Microsoft.DotNet.Tools.Common; - -namespace Microsoft.DotNet.Tools.DependencyInvoker -{ - public class Program - { - public static int Main(string[] args) - { - DebugHelper.HandleDebugSwitch(ref args); - - args = new [] { "dotnet-dependency-tool-invoker" }.Concat(args).ToArray(); - - var parser = new Parser( - options: DotnetDependencyToolInvokerParser.DotnetDependencyToolInvoker()); - - var parseResult = parser.Parse(args); - var appliedOptions = parseResult["dotnet-dependency-tool-invoker"]; - - Console.WriteLine(parseResult.Diagram()); - - if (appliedOptions.HasOption("help")) - { - Console.WriteLine(parseResult.Command().HelpView()); - return 0; - } - - var command = appliedOptions.Arguments.First(); - var framework = appliedOptions.ValueOrDefault("framework"); - var configuration = appliedOptions.ValueOrDefault("configuration"); - if (string.IsNullOrEmpty(configuration)) - { - configuration = Constants.DefaultConfiguration; - } - - var output = appliedOptions.SingleArgumentOrDefault("output"); - var projectPath = appliedOptions.ValueOrDefault("project-path"); - if (string.IsNullOrEmpty(projectPath)) - { - projectPath = PathUtility.EnsureTrailingSlash(Directory.GetCurrentDirectory()); - } - - var appArguments = parseResult.UnmatchedTokens; - - var commandFactory = - new ProjectDependenciesCommandFactory( - framework, - configuration, - output, - string.Empty, - projectPath); - - var result = - InvokeDependencyToolForMSBuild(commandFactory, command, framework, configuration, appArguments); - - return result; - } - - private static int InvokeDependencyToolForMSBuild( - ProjectDependenciesCommandFactory commandFactory, - string command, - NuGetFramework framework, - string configuration, - IEnumerable appArguments) - { - Console.WriteLine($"Invoking '{command}' for '{framework.GetShortFolderName()}'."); - - return InvokeDependencyTool(commandFactory, command, framework, configuration, appArguments); - } - - private static int InvokeDependencyTool( - ProjectDependenciesCommandFactory commandFactory, - string command, - NuGetFramework framework, - string configuration, - IEnumerable appArguments) - { - try - { - var exitCode = commandFactory.Create( - $"dotnet-{command}", - appArguments, - framework, - configuration) - .ForwardStdErr() - .ForwardStdOut() - .Execute() - .ExitCode; - - Console.WriteLine($"Command returned {exitCode}"); - } - catch (CommandUnknownException) - { - Console.WriteLine($"Command not found"); - return 1; - } - - return 0; - } - } -} diff --git a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj deleted file mode 100644 index dd392e365..000000000 --- a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - 1.0.0-rc - netcoreapp3.0 - Exe - - - - - - - - - - - diff --git a/TestAssets/TestProjects/TestAppWithProjDepTool/Program.cs b/TestAssets/TestProjects/TestAppWithProjDepTool/Program.cs deleted file mode 100644 index 20b3f028d..000000000 --- a/TestAssets/TestProjects/TestAppWithProjDepTool/Program.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; - -namespace MSBuildTestApp -{ - public class Program - { - public static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - } - } -} diff --git a/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj b/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj deleted file mode 100644 index 6a4dd2c22..000000000 --- a/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - Exe - netcoreapp3.0 - $(TEST_PACKAGES) - - - - - All - - - - - - - \ No newline at end of file diff --git a/test/EndToEnd/ProjectToolsTests.cs b/test/EndToEnd/ProjectToolsTests.cs index c1e3a145e..7a69726be 100644 --- a/test/EndToEnd/ProjectToolsTests.cs +++ b/test/EndToEnd/ProjectToolsTests.cs @@ -81,47 +81,6 @@ namespace Microsoft.DotNet.Tests.EndToEnd .And.HaveStdOutContaining("Hello I prefer the cli runtime World!");; } - [Fact] - public void ItCanRunAToolThatInvokesADependencyToolInACSProj() - { - var repoDirectoriesProvider = new RepoDirectoriesProvider(); - - var testInstance = TestAssets.Get("TestAppWithProjDepTool") - .CreateInstance() - .WithSourceFiles(); - - var configuration = "Debug"; - - var testProjectDirectory = testInstance.Root; - - new RestoreCommand() - .WithWorkingDirectory(testProjectDirectory) - .WithEnvironmentVariable("NUGET_PACKAGES", TestNuGetCache) - .WithEnvironmentVariable("TEST_PACKAGES", TestPackagesDirectory) - .Execute() - .Should() - .Pass(); - - new BuildCommand() - .WithWorkingDirectory(testProjectDirectory) - .WithEnvironmentVariable("NUGET_PACKAGES", TestNuGetCache) - .WithEnvironmentVariable("TEST_PACKAGES", TestPackagesDirectory) - .Execute($"-c {configuration} ") - .Should() - .Pass(); - - new DotnetCommand() - .WithWorkingDirectory(testProjectDirectory) - .WithEnvironmentVariable("NUGET_PACKAGES", TestNuGetCache) - .WithEnvironmentVariable("TEST_PACKAGES", TestPackagesDirectory) - .ExecuteWithCapturedOutput( - $"-d dependency-tool-invoker -c {configuration} -f netcoreapp3.0 portable") - .Should().Pass() - .And.HaveStdOutContaining("Hello Portable World!"); - } - - - public class TestPackagesFixture { public string TestPackagesDirectory { get; private set; } @@ -156,8 +115,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd var testPackageNames = new[] { "dotnet-portable", - "dotnet-prefercliruntime", - "dotnet-dependency-tool-invoker" + "dotnet-prefercliruntime" }; foreach (var testPackageName in testPackageNames)