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 System.Linq;
|
||||||
using Microsoft.DotNet.ProjectModel;
|
using Microsoft.DotNet.ProjectModel;
|
||||||
using Microsoft.DotNet.Cli.Utils;
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
|
using NuGet.Frameworks;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Tools.DependencyInvoker
|
namespace Microsoft.DotNet.Tools.DependencyInvoker
|
||||||
{
|
{
|
||||||
|
@ -36,18 +37,59 @@ namespace Microsoft.DotNet.Tools.DependencyInvoker
|
||||||
dotnetParams.Config,
|
dotnetParams.Config,
|
||||||
dotnetParams.Output,
|
dotnetParams.Output,
|
||||||
dotnetParams.BuildBasePath,
|
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)
|
foreach (var projectContext in projectContexts)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Invoking '{dotnetParams.Command}' for '{projectContext.TargetFramework}'.");
|
Console.WriteLine($"Invoking '{dotnetParams.Command}' for '{projectContext.TargetFramework}'.");
|
||||||
|
|
||||||
|
if (InvokeDependencyTool(commandFactory, dotnetParams, projectContext.TargetFramework) != 0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int InvokeDependencyTool(
|
||||||
|
ProjectDependenciesCommandFactory commandFactory,
|
||||||
|
DotnetBaseParams dotnetParams,
|
||||||
|
NuGetFramework framework)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var exitCode = commandFactory.Create(
|
var exitCode = commandFactory.Create(
|
||||||
$"dotnet-{dotnetParams.Command}",
|
$"dotnet-{dotnetParams.Command}",
|
||||||
dotnetParams.RemainingArguments,
|
dotnetParams.RemainingArguments,
|
||||||
projectContext.TargetFramework,
|
framework,
|
||||||
dotnetParams.Config)
|
dotnetParams.Config)
|
||||||
.ForwardStdErr()
|
.ForwardStdErr()
|
||||||
.ForwardStdOut()
|
.ForwardStdOut()
|
||||||
|
@ -61,7 +103,7 @@ namespace Microsoft.DotNet.Tools.DependencyInvoker
|
||||||
Console.WriteLine($"Command not found");
|
Console.WriteLine($"Command not found");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +118,7 @@ namespace Microsoft.DotNet.Tools.DependencyInvoker
|
||||||
|
|
||||||
if (!File.Exists(projectPath))
|
if (!File.Exists(projectPath))
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException($"{projectPath} does not exist.");
|
return Enumerable.Empty<ProjectContext>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ProjectContext.CreateContextForEachFramework(projectPath);
|
return ProjectContext.CreateContextForEachFramework(projectPath);
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
},
|
},
|
||||||
"Microsoft.DotNet.Compiler.Common": {
|
"Microsoft.DotNet.Compiler.Common": {
|
||||||
"target": "project"
|
"target": "project"
|
||||||
}
|
},
|
||||||
|
"NuGet.Frameworks": "3.6.0-rc-1979"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"netcoreapp1.0": {
|
"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>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<DotNetCliToolReference Include="dotnet-invoke-portable">
|
<DotNetCliToolReference Include="dotnet-dependency-tool-invoker">
|
||||||
<Version>1.0.0-rc-*</Version>
|
<Version>1.0.0-*</Version>
|
||||||
</DotNetCliToolReference>
|
</DotNetCliToolReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -142,15 +142,6 @@
|
||||||
<Clean>True</Clean>
|
<Clean>True</Clean>
|
||||||
<Frameworks>netcoreapp1.0</Frameworks>
|
<Frameworks>netcoreapp1.0</Frameworks>
|
||||||
</BaseTestPackageProject>
|
</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">
|
<BaseTestPackageProject Include="TestAssets/TestPackages/ToolWithOutputName">
|
||||||
<Name>dotnet-tool-with-output-name</Name>
|
<Name>dotnet-tool-with-output-name</Name>
|
||||||
<NuPkgName>ToolWithOutputName</NuPkgName>
|
<NuPkgName>ToolWithOutputName</NuPkgName>
|
||||||
|
|
|
@ -108,7 +108,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
||||||
|
|
||||||
new DotnetCommand()
|
new DotnetCommand()
|
||||||
.WithWorkingDirectory(testProjectDirectory)
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
.ExecuteWithCapturedOutput("invoke-portable")
|
.ExecuteWithCapturedOutput("dependency-tool-invoker -f netcoreapp1.0 portable")
|
||||||
.Should()
|
.Should()
|
||||||
.Pass()
|
.Pass()
|
||||||
.And
|
.And
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue