Moving the ProjectToolsCommandResolver to dotnet out of Cli.Utils because of the dependency on Microsoft.Build. Also added a EndToEnd test for tools ref using the MSBuildTestApp.
This commit is contained in:
parent
12e8e8eca7
commit
1570e0fde4
21 changed files with 186 additions and 29 deletions
|
@ -21,5 +21,11 @@
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<DotNetCliToolsReference Include="dotnet-portable">
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
</DotNetCliToolsReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
|
@ -63,7 +63,28 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
string outputPath = null,
|
string outputPath = null,
|
||||||
string applicationName = null)
|
string applicationName = null)
|
||||||
{
|
{
|
||||||
var commandSpec = CommandResolver.TryResolveCommandSpec(commandName,
|
return Create(
|
||||||
|
new DefaultCommandResolverPolicy(),
|
||||||
|
commandName,
|
||||||
|
args,
|
||||||
|
framework,
|
||||||
|
configuration,
|
||||||
|
outputPath,
|
||||||
|
applicationName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Command Create(
|
||||||
|
ICommandResolverPolicy commandResolverPolicy,
|
||||||
|
string commandName,
|
||||||
|
IEnumerable<string> args,
|
||||||
|
NuGetFramework framework = null,
|
||||||
|
string configuration = Constants.DefaultConfiguration,
|
||||||
|
string outputPath = null,
|
||||||
|
string applicationName = null)
|
||||||
|
{
|
||||||
|
var commandSpec = CommandResolver.TryResolveCommandSpec(
|
||||||
|
commandResolverPolicy,
|
||||||
|
commandName,
|
||||||
args,
|
args,
|
||||||
framework,
|
framework,
|
||||||
configuration: configuration,
|
configuration: configuration,
|
||||||
|
|
|
@ -2,8 +2,13 @@ using Microsoft.DotNet.PlatformAbstractions;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils
|
namespace Microsoft.DotNet.Cli.Utils
|
||||||
{
|
{
|
||||||
public class DefaultCommandResolverPolicy
|
public class DefaultCommandResolverPolicy : ICommandResolverPolicy
|
||||||
{
|
{
|
||||||
|
public CompositeCommandResolver CreateCommandResolver()
|
||||||
|
{
|
||||||
|
return Create();
|
||||||
|
}
|
||||||
|
|
||||||
public static CompositeCommandResolver Create()
|
public static CompositeCommandResolver Create()
|
||||||
{
|
{
|
||||||
var environment = new EnvironmentProvider();
|
var environment = new EnvironmentProvider();
|
||||||
|
@ -37,7 +42,6 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
|
|
||||||
compositeCommandResolver.AddCommandResolver(new MuxerCommandResolver());
|
compositeCommandResolver.AddCommandResolver(new MuxerCommandResolver());
|
||||||
compositeCommandResolver.AddCommandResolver(new RootedCommandResolver());
|
compositeCommandResolver.AddCommandResolver(new RootedCommandResolver());
|
||||||
compositeCommandResolver.AddCommandResolver(new ProjectToolsCommandResolver(packagedCommandSpecFactory));
|
|
||||||
compositeCommandResolver.AddCommandResolver(new AppBaseDllCommandResolver());
|
compositeCommandResolver.AddCommandResolver(new AppBaseDllCommandResolver());
|
||||||
compositeCommandResolver.AddCommandResolver(
|
compositeCommandResolver.AddCommandResolver(
|
||||||
new AppBaseCommandResolver(environment, platformCommandSpecFactory));
|
new AppBaseCommandResolver(environment, platformCommandSpecFactory));
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace Microsoft.DotNet.Cli.Utils
|
||||||
|
{
|
||||||
|
public interface ICommandResolverPolicy
|
||||||
|
{
|
||||||
|
CompositeCommandResolver CreateCommandResolver();
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ using NuGet.Frameworks;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils
|
namespace Microsoft.DotNet.Cli.Utils
|
||||||
{
|
{
|
||||||
internal static class CommandResolver
|
internal class CommandResolver
|
||||||
{
|
{
|
||||||
public static CommandSpec TryResolveCommandSpec(
|
public static CommandSpec TryResolveCommandSpec(
|
||||||
string commandName,
|
string commandName,
|
||||||
|
@ -14,6 +14,25 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
string configuration = Constants.DefaultConfiguration,
|
string configuration = Constants.DefaultConfiguration,
|
||||||
string outputPath = null,
|
string outputPath = null,
|
||||||
string applicationName = null)
|
string applicationName = null)
|
||||||
|
{
|
||||||
|
return TryResolveCommandSpec(
|
||||||
|
new DefaultCommandResolverPolicy(),
|
||||||
|
commandName,
|
||||||
|
args,
|
||||||
|
framework,
|
||||||
|
configuration,
|
||||||
|
outputPath,
|
||||||
|
applicationName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CommandSpec TryResolveCommandSpec(
|
||||||
|
ICommandResolverPolicy commandResolverPolicy,
|
||||||
|
string commandName,
|
||||||
|
IEnumerable<string> args,
|
||||||
|
NuGetFramework framework = null,
|
||||||
|
string configuration = Constants.DefaultConfiguration,
|
||||||
|
string outputPath = null,
|
||||||
|
string applicationName = null)
|
||||||
{
|
{
|
||||||
var commandResolverArgs = new CommandResolverArguments
|
var commandResolverArgs = new CommandResolverArguments
|
||||||
{
|
{
|
||||||
|
@ -26,7 +45,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
ApplicationName = applicationName
|
ApplicationName = applicationName
|
||||||
};
|
};
|
||||||
|
|
||||||
var defaultCommandResolver = DefaultCommandResolverPolicy.Create();
|
var defaultCommandResolver = commandResolverPolicy.CreateCommandResolver();
|
||||||
|
|
||||||
return defaultCommandResolver.Resolve(commandResolverArgs);
|
return defaultCommandResolver.Resolve(commandResolverArgs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,13 @@ using NuGet.Packaging;
|
||||||
using NuGet.Packaging.Core;
|
using NuGet.Packaging.Core;
|
||||||
using NuGet.ProjectModel;
|
using NuGet.ProjectModel;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils
|
namespace Microsoft.DotNet.Cli.CommandResolution
|
||||||
{
|
{
|
||||||
internal class DependencyContextBuilder
|
internal class DepsJsonBuilder
|
||||||
{
|
{
|
||||||
private readonly VersionFolderPathResolver _versionFolderPathResolver;
|
private readonly VersionFolderPathResolver _versionFolderPathResolver;
|
||||||
|
|
||||||
public DependencyContextBuilder()
|
public DepsJsonBuilder()
|
||||||
{
|
{
|
||||||
// This resolver is only used for building file names, so that base path is not required.
|
// This resolver is only used for building file names, so that base path is not required.
|
||||||
_versionFolderPathResolver = new VersionFolderPathResolver(path: null);
|
_versionFolderPathResolver = new VersionFolderPathResolver(path: null);
|
|
@ -2,11 +2,13 @@
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.Build.Execution;
|
using System.Linq;
|
||||||
|
using Microsoft.Build.Evaluation;
|
||||||
using NuGet.ProjectModel;
|
using NuGet.ProjectModel;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils
|
namespace Microsoft.DotNet.Cli.CommandResolution
|
||||||
{
|
{
|
||||||
internal class LockFilePathCalculator
|
internal class LockFilePathCalculator
|
||||||
{
|
{
|
||||||
|
@ -19,12 +21,21 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
private string ResolveLockFilePathUsingCSProj(string projectDirectory)
|
private string ResolveLockFilePathUsingCSProj(string projectDirectory)
|
||||||
{
|
{
|
||||||
string csProjPath = GetCSProjPath(projectDirectory);
|
string csProjPath = GetCSProjPath(projectDirectory);
|
||||||
if(csProjPath != null)
|
if(csProjPath == null)
|
||||||
{
|
{
|
||||||
ProjectInstance projectInstance = new ProjectInstance(csProjPath, null, null);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
var globalProperties = new Dictionary<string, string>()
|
||||||
|
{
|
||||||
|
{ "MSBuildExtensionsPath", AppContext.BaseDirectory }
|
||||||
|
};
|
||||||
|
|
||||||
|
Project project = new Project(csProjPath, globalProperties, null);
|
||||||
|
// TODO: This is temporary. We should use ProjectLockFile property, but for some reason, it is coming up as project.lock.json
|
||||||
|
// instead of the path to project.assets.json.
|
||||||
|
var lockFilePath = project.AllEvaluatedProperties.FirstOrDefault(p => p.Name.Equals("BaseIntermediateOutputPath")).EvaluatedValue;
|
||||||
|
return Path.Combine(lockFilePath, "project.assets.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ReturnProjectLockJson(string projectDirectory)
|
private string ReturnProjectLockJson(string projectDirectory)
|
|
@ -7,7 +7,7 @@ using System.Linq;
|
||||||
using NuGet.Packaging.Core;
|
using NuGet.Packaging.Core;
|
||||||
using NuGet.ProjectModel;
|
using NuGet.ProjectModel;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils
|
namespace Microsoft.DotNet.Cli.CommandResolution
|
||||||
{
|
{
|
||||||
internal static class LockFileTargetExtensions
|
internal static class LockFileTargetExtensions
|
||||||
{
|
{
|
|
@ -8,7 +8,7 @@ using System.Linq;
|
||||||
using NuGet.Packaging.Core;
|
using NuGet.Packaging.Core;
|
||||||
using NuGet.ProjectModel;
|
using NuGet.ProjectModel;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils
|
namespace Microsoft.DotNet.Cli.CommandResolution
|
||||||
{
|
{
|
||||||
internal static class NuGetUtils
|
internal static class NuGetUtils
|
||||||
{
|
{
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
using Microsoft.DotNet.InternalAbstractions;
|
using Microsoft.DotNet.InternalAbstractions;
|
||||||
using Microsoft.DotNet.ProjectModel;
|
using Microsoft.DotNet.ProjectModel;
|
||||||
using Microsoft.DotNet.Tools.Common;
|
using Microsoft.DotNet.Tools.Common;
|
||||||
|
@ -11,7 +12,7 @@ using NuGet.ProjectModel;
|
||||||
using NuGet.Versioning;
|
using NuGet.Versioning;
|
||||||
using FileFormatException = Microsoft.DotNet.ProjectModel.FileFormatException;
|
using FileFormatException = Microsoft.DotNet.ProjectModel.FileFormatException;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils
|
namespace Microsoft.DotNet.Cli.CommandResolution
|
||||||
{
|
{
|
||||||
public class ProjectToolsCommandResolver : ICommandResolver
|
public class ProjectToolsCommandResolver : ICommandResolver
|
||||||
{
|
{
|
||||||
|
@ -52,7 +53,8 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
IEnumerable<string> args,
|
IEnumerable<string> args,
|
||||||
string projectDirectory)
|
string projectDirectory)
|
||||||
{
|
{
|
||||||
var lockFile = new LockFileFormat().Read(Path.Combine(projectDirectory, LockFileFormat.LockFileName));
|
var lockFilePathCalculator = new LockFilePathCalculator();
|
||||||
|
var lockFile = new LockFileFormat().Read(lockFilePathCalculator.GetLockFilePath(projectDirectory));
|
||||||
var tools = lockFile.Tools.Where(t => t.Name.Contains(".NETCoreApp")).SelectMany(t => t.Libraries);
|
var tools = lockFile.Tools.Where(t => t.Name.Contains(".NETCoreApp")).SelectMany(t => t.Libraries);
|
||||||
|
|
||||||
return ResolveCommandSpecFromAllToolLibraries(
|
return ResolveCommandSpecFromAllToolLibraries(
|
||||||
|
@ -209,7 +211,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
toolLibrary.Version.ToFullString(),
|
toolLibrary.Version.ToFullString(),
|
||||||
Enumerable.Empty<ResourceAssemblyInfo>());
|
Enumerable.Empty<ResourceAssemblyInfo>());
|
||||||
|
|
||||||
var dependencyContext = new DependencyContextBuilder()
|
var dependencyContext = new DepsJsonBuilder()
|
||||||
.Build(singleProjectInfo, null, toolLockFile, s_toolPackageFramework, null);
|
.Build(singleProjectInfo, null, toolLockFile, s_toolPackageFramework, null);
|
||||||
|
|
||||||
var tempDepsFile = Path.GetTempFileName();
|
var tempDepsFile = Path.GetTempFileName();
|
|
@ -0,0 +1,18 @@
|
||||||
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli.CommandResolution
|
||||||
|
{
|
||||||
|
public class ProjectToolsCommandResolverPolicy : ICommandResolverPolicy
|
||||||
|
{
|
||||||
|
public CompositeCommandResolver CreateCommandResolver()
|
||||||
|
{
|
||||||
|
var defaultCommandResolverPolicy = new DefaultCommandResolverPolicy();
|
||||||
|
var compositeCommandResolver = defaultCommandResolverPolicy.CreateCommandResolver();
|
||||||
|
var packagedCommandSpecFactory = new PackagedCommandSpecFactory();
|
||||||
|
|
||||||
|
compositeCommandResolver.AddCommandResolver(new ProjectToolsCommandResolver(packagedCommandSpecFactory));
|
||||||
|
|
||||||
|
return compositeCommandResolver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
// 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.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils
|
namespace Microsoft.DotNet.Cli.CommandResolution
|
||||||
{
|
{
|
||||||
internal class ResourceAssemblyInfo
|
internal class ResourceAssemblyInfo
|
||||||
{
|
{
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils
|
namespace Microsoft.DotNet.Cli.CommandResolution
|
||||||
{
|
{
|
||||||
internal class SingleProjectInfo
|
internal class SingleProjectInfo
|
||||||
{
|
{
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Microsoft.DotNet.Cli.CommandResolution;
|
||||||
using Microsoft.DotNet.Cli.Utils;
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
using Microsoft.DotNet.Configurer;
|
using Microsoft.DotNet.Configurer;
|
||||||
using Microsoft.DotNet.PlatformAbstractions;
|
using Microsoft.DotNet.PlatformAbstractions;
|
||||||
|
@ -188,7 +189,12 @@ namespace Microsoft.DotNet.Cli
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CommandResult result = Command.Create("dotnet-" + command, appArgs, FrameworkConstants.CommonFrameworks.NetStandardApp15)
|
var projectToolsCommandResolver = new ProjectToolsCommandResolverPolicy();
|
||||||
|
CommandResult result = Command.Create(
|
||||||
|
projectToolsCommandResolver,
|
||||||
|
"dotnet-" + command,
|
||||||
|
appArgs,
|
||||||
|
FrameworkConstants.CommonFrameworks.NetStandardApp15)
|
||||||
.Execute();
|
.Execute();
|
||||||
exitCode = result.ExitCode;
|
exitCode = result.ExitCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,5 +43,27 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
||||||
.HaveStdOutContaining("Hello World!");
|
.HaveStdOutContaining("Hello World!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ItCanRunToolsInACSProj()
|
||||||
|
{
|
||||||
|
var testAppName = "MSBuildTestApp";
|
||||||
|
var testInstance = TestAssetsManager
|
||||||
|
.CreateTestInstance(testAppName);
|
||||||
|
|
||||||
|
var testProjectDirectory = testInstance.TestRoot;
|
||||||
|
|
||||||
|
new Restore3Command()
|
||||||
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
|
.Execute()
|
||||||
|
.Should()
|
||||||
|
.Pass();
|
||||||
|
|
||||||
|
new DotnetCommand()
|
||||||
|
.WithWorkingDirectory(testInstance.TestRoot)
|
||||||
|
.ExecuteWithCapturedOutput("portable")
|
||||||
|
.Should()
|
||||||
|
.Pass();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
|
|
||||||
var resolvers = defaultCommandResolver.OrderedCommandResolvers;
|
var resolvers = defaultCommandResolver.OrderedCommandResolvers;
|
||||||
|
|
||||||
resolvers.Should().HaveCount(7);
|
resolvers.Should().HaveCount(6);
|
||||||
|
|
||||||
resolvers.Select(r => r.GetType())
|
resolvers.Select(r => r.GetType())
|
||||||
.Should()
|
.Should()
|
||||||
|
@ -25,7 +25,6 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
new []{
|
new []{
|
||||||
typeof(MuxerCommandResolver),
|
typeof(MuxerCommandResolver),
|
||||||
typeof(RootedCommandResolver),
|
typeof(RootedCommandResolver),
|
||||||
typeof(ProjectToolsCommandResolver),
|
|
||||||
typeof(AppBaseDllCommandResolver),
|
typeof(AppBaseDllCommandResolver),
|
||||||
typeof(AppBaseCommandResolver),
|
typeof(AppBaseCommandResolver),
|
||||||
typeof(PathCommandResolver),
|
typeof(PathCommandResolver),
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
},
|
},
|
||||||
"System.Diagnostics.TraceSource": "4.0.0",
|
"System.Diagnostics.TraceSource": "4.0.0",
|
||||||
"System.Runtime.Serialization.Primitives": "4.1.1",
|
"System.Runtime.Serialization.Primitives": "4.1.1",
|
||||||
"NuGet.Versioning": "3.6.0-beta.1.msbuild.15",
|
"NuGet.Versioning": "3.6.0-beta.1.msbuild.17",
|
||||||
"NuGet.Packaging": "3.6.0-beta.1.msbuild.15",
|
"NuGet.Packaging": "3.6.0-beta.1.msbuild.17",
|
||||||
"NuGet.Frameworks": "3.6.0-beta.1.msbuild.15",
|
"NuGet.Frameworks": "3.6.0-beta.1.msbuild.17",
|
||||||
"NuGet.ProjectModel": "3.6.0-beta.1.msbuild.15",
|
"NuGet.ProjectModel": "3.6.0-beta.1.msbuild.17",
|
||||||
"Microsoft.DotNet.ProjectModel": {
|
"Microsoft.DotNet.ProjectModel": {
|
||||||
"target": "project"
|
"target": "project"
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
},
|
},
|
||||||
"xunit": "2.2.0-beta3-build3330",
|
"xunit": "2.2.0-beta3-build3330",
|
||||||
"dotnet-test-xunit": "1.0.0-rc2-350904-49",
|
"dotnet-test-xunit": "1.0.0-rc2-350904-49",
|
||||||
"NuGet.ProjectModel": "3.6.0-beta.1.msbuild.15"
|
"NuGet.ProjectModel": "3.6.0-beta.1.msbuild.17"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"netcoreapp1.0": {
|
"netcoreapp1.0": {
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using Microsoft.DotNet.Cli.CommandResolution;
|
||||||
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
using Microsoft.DotNet.ProjectModel;
|
using Microsoft.DotNet.ProjectModel;
|
||||||
using Microsoft.DotNet.TestFramework;
|
using Microsoft.DotNet.TestFramework;
|
||||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
|
@ -12,7 +14,7 @@ using NuGet.ProjectModel;
|
||||||
using NuGet.Versioning;
|
using NuGet.Versioning;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils.Tests
|
namespace Microsoft.DotNet.Tests
|
||||||
{
|
{
|
||||||
public class GivenAProjectToolsCommandResolver : TestBase
|
public class GivenAProjectToolsCommandResolver : TestBase
|
||||||
{
|
{
|
39
test/dotnet.Tests/GivenAProjectToolsCommandResolverPolicy.cs
Normal file
39
test/dotnet.Tests/GivenAProjectToolsCommandResolverPolicy.cs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
// 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.Linq;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Microsoft.DotNet.Cli.CommandResolution;
|
||||||
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Tests
|
||||||
|
{
|
||||||
|
public class GivenAProjectToolsCommandResolverPolicy
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void It_contains_resolvers_in_the_right_order()
|
||||||
|
{
|
||||||
|
var projectToolsCommandResolverPolicy = new ProjectToolsCommandResolverPolicy();
|
||||||
|
var defaultCommandResolver = projectToolsCommandResolverPolicy.CreateCommandResolver();
|
||||||
|
|
||||||
|
var resolvers = defaultCommandResolver.OrderedCommandResolvers;
|
||||||
|
|
||||||
|
resolvers.Should().HaveCount(7);
|
||||||
|
|
||||||
|
resolvers.Select(r => r.GetType())
|
||||||
|
.Should()
|
||||||
|
.ContainInOrder(
|
||||||
|
new []{
|
||||||
|
typeof(MuxerCommandResolver),
|
||||||
|
typeof(RootedCommandResolver),
|
||||||
|
typeof(AppBaseDllCommandResolver),
|
||||||
|
typeof(AppBaseCommandResolver),
|
||||||
|
typeof(PathCommandResolver),
|
||||||
|
typeof(PublishedPathCommandResolver),
|
||||||
|
typeof(ProjectToolsCommandResolver)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ namespace Microsoft.DotNet.Tests
|
||||||
.HaveFile("project.lock.json");
|
.HaveFile("project.lock.json");
|
||||||
|
|
||||||
new DotnetCommand()
|
new DotnetCommand()
|
||||||
|
.WithWorkingDirectory(testInstance.TestRoot)
|
||||||
.ExecuteWithCapturedOutput("crash")
|
.ExecuteWithCapturedOutput("crash")
|
||||||
.Should()
|
.Should()
|
||||||
.Fail()
|
.Fail()
|
||||||
|
|
Loading…
Reference in a new issue