Addressing code review comments by removing unnecessary test artifacts.
This commit is contained in:
parent
d779ab3e3f
commit
d8a10024e5
7 changed files with 66 additions and 81 deletions
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.DependencyInvoker
|
||||
{
|
||||
|
@ -36,32 +37,73 @@ namespace Microsoft.DotNet.Tools.DependencyInvoker
|
|||
dotnetParams.Config,
|
||||
dotnetParams.Output,
|
||||
dotnetParams.BuildBasePath,
|
||||
projectContexts.First().ProjectDirectory);
|
||||
|
||||
dotnetParams.ProjectPath);
|
||||
|
||||
var result = 0;
|
||||
if(projectContexts.Any())
|
||||
{
|
||||
result = InvokeDependencyToolForProjectJson(projectContexts, commandFactory, dotnetParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = InvokeDependencyToolForMSBuild(commandFactory, dotnetParams);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int InvokeDependencyToolForMSBuild(
|
||||
ProjectDependenciesCommandFactory commandFactory,
|
||||
DotnetBaseParams dotnetParams)
|
||||
{
|
||||
Console.WriteLine($"Invoking '{dotnetParams.Command}' for '{dotnetParams.Framework.GetShortFolderName()}'.");
|
||||
|
||||
return InvokeDependencyTool(commandFactory, dotnetParams, dotnetParams.Framework);
|
||||
}
|
||||
|
||||
private static int InvokeDependencyToolForProjectJson(
|
||||
IEnumerable<ProjectContext> projectContexts,
|
||||
ProjectDependenciesCommandFactory commandFactory,
|
||||
DotnetBaseParams dotnetParams)
|
||||
{
|
||||
foreach (var projectContext in projectContexts)
|
||||
{
|
||||
Console.WriteLine($"Invoking '{dotnetParams.Command}' for '{projectContext.TargetFramework}'.");
|
||||
|
||||
try
|
||||
if (InvokeDependencyTool(commandFactory, dotnetParams, projectContext.TargetFramework) != 0)
|
||||
{
|
||||
var exitCode = commandFactory.Create(
|
||||
$"dotnet-{dotnetParams.Command}",
|
||||
dotnetParams.RemainingArguments,
|
||||
projectContext.TargetFramework,
|
||||
dotnetParams.Config)
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute()
|
||||
.ExitCode;
|
||||
|
||||
Console.WriteLine($"Command returned {exitCode}");
|
||||
}
|
||||
catch (CommandUnknownException)
|
||||
{
|
||||
Console.WriteLine($"Command not found");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int InvokeDependencyTool(
|
||||
ProjectDependenciesCommandFactory commandFactory,
|
||||
DotnetBaseParams dotnetParams,
|
||||
NuGetFramework framework)
|
||||
{
|
||||
try
|
||||
{
|
||||
var exitCode = commandFactory.Create(
|
||||
$"dotnet-{dotnetParams.Command}",
|
||||
dotnetParams.RemainingArguments,
|
||||
framework,
|
||||
dotnetParams.Config)
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute()
|
||||
.ExitCode;
|
||||
|
||||
Console.WriteLine($"Command returned {exitCode}");
|
||||
}
|
||||
catch (CommandUnknownException)
|
||||
{
|
||||
Console.WriteLine($"Command not found");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -76,7 +118,7 @@ namespace Microsoft.DotNet.Tools.DependencyInvoker
|
|||
|
||||
if (!File.Exists(projectPath))
|
||||
{
|
||||
throw new InvalidOperationException($"{projectPath} does not exist.");
|
||||
return Enumerable.Empty<ProjectContext>();
|
||||
}
|
||||
|
||||
return ProjectContext.CreateContextForEachFramework(projectPath);
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
},
|
||||
"Microsoft.DotNet.Compiler.Common": {
|
||||
"target": "project"
|
||||
}
|
||||
},
|
||||
"NuGet.Frameworks": "3.6.0-rc-1979"
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var environment = new EnvironmentProvider();
|
||||
var packagedCommandSpecFactory = new PackagedCommandSpecFactory();
|
||||
|
||||
var projectDependenciesCommandFactory = new ProjectDependenciesCommandFactory(
|
||||
FrameworkConstants.CommonFrameworks.NetCoreApp10,
|
||||
"Debug",
|
||||
null,
|
||||
null,
|
||||
Directory.GetCurrentDirectory());
|
||||
|
||||
var command = projectDependenciesCommandFactory.Create("dotnet-portable", null);
|
||||
|
||||
command.Execute();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"version": "1.0.0-rc-*",
|
||||
"buildOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"target": "project"
|
||||
},
|
||||
"NuGet.Frameworks": "3.6.0-rc-1954"
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,8 +27,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="dotnet-invoke-portable">
|
||||
<Version>1.0.0-rc-*</Version>
|
||||
<DotNetCliToolReference Include="dotnet-dependency-tool-invoker">
|
||||
<Version>1.0.0-*</Version>
|
||||
</DotNetCliToolReference>
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -142,15 +142,6 @@
|
|||
<Clean>True</Clean>
|
||||
<Frameworks>netcoreapp1.0</Frameworks>
|
||||
</BaseTestPackageProject>
|
||||
<BaseTestPackageProject Include="TestAssets/TestPackages/dotnet-invoke-portable">
|
||||
<Name>dotnet-invoke-portable</Name>
|
||||
<IsTool>True</IsTool>
|
||||
<IsApplicable>True</IsApplicable>
|
||||
<VersionPrefix>1.0.0-rc-</VersionPrefix>
|
||||
<VersionSuffix>$(TestPackageBuildVersionSuffix)</VersionSuffix>
|
||||
<Clean>True</Clean>
|
||||
<Frameworks>netcoreapp1.0</Frameworks>
|
||||
</BaseTestPackageProject>
|
||||
<BaseTestPackageProject Include="TestAssets/TestPackages/ToolWithOutputName">
|
||||
<Name>dotnet-tool-with-output-name</Name>
|
||||
<NuPkgName>ToolWithOutputName</NuPkgName>
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
|
||||
new DotnetCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput("invoke-portable")
|
||||
.ExecuteWithCapturedOutput("dependency-tool-invoker -f netcoreapp1.0 portable")
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
|
|
Loading…
Reference in a new issue