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.
This commit is contained in:
parent
6fd4a5afad
commit
b757854508
7 changed files with 1 additions and 289 deletions
|
@ -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<T>(this AppliedOption parseResult, string alias)
|
||||
{
|
||||
return parseResult
|
||||
.AppliedOptions
|
||||
.Where(o => o.HasAlias(alias))
|
||||
.Select(o => o.Value<T>())
|
||||
.SingleOrDefault();
|
||||
}
|
||||
|
||||
public static string SingleArgumentOrDefault(this AppliedOption parseResult, string alias)
|
||||
{
|
||||
return parseResult
|
||||
.AppliedOptions
|
||||
.Where(o => o.HasAlias(alias))
|
||||
.Select(o => o.Arguments.Single())
|
||||
.SingleOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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")));
|
||||
}
|
||||
}
|
|
@ -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<NuGetFramework>("framework");
|
||||
var configuration = appliedOptions.ValueOrDefault<string>("configuration");
|
||||
if (string.IsNullOrEmpty(configuration))
|
||||
{
|
||||
configuration = Constants.DefaultConfiguration;
|
||||
}
|
||||
|
||||
var output = appliedOptions.SingleArgumentOrDefault("output");
|
||||
var projectPath = appliedOptions.ValueOrDefault<string>("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<string> 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<string> 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>1.0.0-rc</VersionPrefix>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<VersionSuffix></VersionSuffix>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NuGet.Frameworks" Version="4.8.0-rtm.5348" />
|
||||
<PackageReference Include="Microsoft.DotNet.Cli.Utils" Version="3.0.100-alpha1-20180711-1" />
|
||||
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="0.1.1" />
|
||||
<PackageReference Include="System.Linq" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<RestoreAdditionalProjectSources Condition="'$(TEST_PACKAGES)' != ''">$(TEST_PACKAGES)</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="dotnet-portable" Version="1.0.0" >
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="dotnet-dependency-tool-invoker" Version="1.0.0-*" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue