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 88edf2f41..000000000 --- a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 1.0.0-rc - $(CliTargetFramework) - Exe - - $(MicrosoftNETCoreAppPackageVersion) - - - - - - - - - - - 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 d05c83d53..000000000 --- a/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - - Exe - $(CliTargetFramework) - $(TEST_PACKAGES) - - - - - All - - - - - - - \ No newline at end of file diff --git a/build/TestDependencyVersions.props b/build/TestDependencyVersions.props index c3aa91056..671c82cf4 100644 --- a/build/TestDependencyVersions.props +++ b/build/TestDependencyVersions.props @@ -1,7 +1,7 @@ - 4.8.0-rtm.5348 - 3.0.100-alpha1-20180711-1 + 5.0.0-preview1.5663 + 3.0.100-preview.18580.6 0.1.1 15.8.0 3.0.0-preview-27205-02 diff --git a/build/test/TestPackageProjects.targets b/build/test/TestPackageProjects.targets index 6e3f496f5..82230a578 100644 --- a/build/test/TestPackageProjects.targets +++ b/build/test/TestPackageProjects.targets @@ -20,16 +20,6 @@ - - dotnet-dependency-tool-invoker - dotnet-dependency-tool-invoker.csproj - True - True - $(CliVersionPrefix) - $(VersionSuffix) - $(ReleaseSuffix) - True - dotnet-portable dotnet-portable.csproj diff --git a/test/EndToEnd/GivenDotNetUsesMSBuild.cs b/test/EndToEnd/GivenDotNetUsesMSBuild.cs index 474bcf14c..7f126b2d3 100644 --- a/test/EndToEnd/GivenDotNetUsesMSBuild.cs +++ b/test/EndToEnd/GivenDotNetUsesMSBuild.cs @@ -95,33 +95,5 @@ namespace Microsoft.DotNet.Tests.EndToEnd .Should().Pass() .And.HaveStdOutContaining("Hello I prefer the cli runtime World!");; } - - [Fact(Skip="https://github.com/dotnet/cli/issues/9688")] - public void ItCanRunAToolThatInvokesADependencyToolInACSProj() - { - var repoDirectoriesProvider = new RepoDirectoriesProvider(); - - var testInstance = TestAssets.Get("TestAppWithProjDepTool") - .CreateInstance() - .WithSourceFiles() - .WithRestoreFiles(); - - var configuration = "Debug"; - - var testProjectDirectory = testInstance.Root; - - new BuildCommand() - .WithWorkingDirectory(testProjectDirectory) - .Execute($"-c {configuration} ") - .Should() - .Pass(); - - new DotnetCommand() - .WithWorkingDirectory(testProjectDirectory) - .ExecuteWithCapturedOutput( - $"-d dependency-tool-invoker -c {configuration} -f netcoreapp3.0 portable") - .Should().Pass() - .And.HaveStdOutContaining("Hello Portable World!");; - } } } diff --git a/test/Microsoft.DotNet.TestFramework/Microsoft.DotNet.TestFramework.csproj b/test/Microsoft.DotNet.TestFramework/Microsoft.DotNet.TestFramework.csproj index 75dbb31cf..645ef70a9 100644 --- a/test/Microsoft.DotNet.TestFramework/Microsoft.DotNet.TestFramework.csproj +++ b/test/Microsoft.DotNet.TestFramework/Microsoft.DotNet.TestFramework.csproj @@ -3,7 +3,7 @@ Microsoft.DotNet.TestFramework Class Library $(CliVersionPrefix) - netstandard2.0 + netcoreapp3.0 ../../tools/Key.snk true true diff --git a/test/Microsoft.DotNet.TestFramework/TestAssetInstance.cs b/test/Microsoft.DotNet.TestFramework/TestAssetInstance.cs index 93509a21a..2d02b1ec4 100644 --- a/test/Microsoft.DotNet.TestFramework/TestAssetInstance.cs +++ b/test/Microsoft.DotNet.TestFramework/TestAssetInstance.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; @@ -251,7 +252,7 @@ namespace Microsoft.DotNet.TestFramework Console.WriteLine($"TestAsset Build '{TestAssetInfo.AssetName}'"); - var commandResult = Command.Create(TestAssetInfo.DotnetExeFile.FullName, args) + var commandResult = CreateCommand(TestAssetInfo.DotnetExeFile.FullName, args) .WorkingDirectory(Root.FullName) .CaptureStdOut() .CaptureStdErr() @@ -280,7 +281,7 @@ namespace Microsoft.DotNet.TestFramework { var restoreArgs = new string[] { "restore", projectFile.FullName }; - var commandResult = Command.Create(TestAssetInfo.DotnetExeFile.FullName, restoreArgs) + var commandResult = CreateCommand(TestAssetInfo.DotnetExeFile.FullName, restoreArgs) .CaptureStdOut() .CaptureStdErr() .Execute(); @@ -308,5 +309,23 @@ namespace Microsoft.DotNet.TestFramework Restore(projFile); } } + + private static Command CreateCommand(string path, IEnumerable args) + { + var psi = new ProcessStartInfo + { + FileName = path, + Arguments = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args), + UseShellExecute = false + }; + + + var _process = new Process + { + StartInfo = psi + }; + + return new Command(_process); + } } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Microsoft.DotNet.Tools.Tests.Utilities.csproj b/test/Microsoft.DotNet.Tools.Tests.Utilities/Microsoft.DotNet.Tools.Tests.Utilities.csproj index 3bd17e138..55f17698e 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Microsoft.DotNet.Tools.Tests.Utilities.csproj +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Microsoft.DotNet.Tools.Tests.Utilities.csproj @@ -1,7 +1,7 @@  Microsoft.DotNet.Tools.Tests.Utilities Class Library - netstandard2.0 + netcoreapp3.0 Microsoft.DotNet.Tools.Tests.Utilities ../../tools/Key.snk true