private CommandSpec GetPackageCommandSpecUsingMuxer(CommandResolverArguments arguments, ToolCommandName toolCommandName) { if (!_toolManifest.TryFind(toolCommandName, out var toolManifestPackage)) { return(null); } if (_localToolsResolverCache.TryLoad( new RestoredCommandIdentifier( toolManifestPackage.PackageId, toolManifestPackage.Version, NuGetFramework.Parse(BundledTargetFramework.GetTargetFrameworkMoniker()), Constants.AnyRid, toolCommandName), _nugetGlobalPackagesFolder, out var restoredCommand)) { if (!_fileSystem.File.Exists(restoredCommand.Executable.Value)) { throw new GracefulException(string.Format(LocalizableStrings.NeedRunToolRestore, toolCommandName.ToString())); } return(MuxerCommandSpecMaker.CreatePackageCommandSpecUsingMuxer( restoredCommand.Executable.Value, arguments.CommandArguments)); } return(null); }
public void GivenInvalidJsonManifestFileWhenFindByCommandNameItThrows() { _fileSystem.File.WriteAllText(Path.Combine(_testDirectoryRoot, _manifestFilename), _jsonContentInvalidJson); var toolManifest = new ToolManifestFinder(new DirectoryPath(_testDirectoryRoot), _fileSystem); Action a = () => toolManifest.TryFind(new ToolCommandName("dotnetSay"), out var result); a.ShouldThrow <ToolManifestException>(); }
public void GivenNoManifestFileWhenFindByCommandNameItReturnFalse() { var toolManifest = new ToolManifestFinder( new DirectoryPath(_testDirectoryRoot), _fileSystem, new FakeDangerousFileDetector()); toolManifest.TryFind(new ToolCommandName("dotnetSay"), out var result).Should().BeFalse(); }
public void DifferentVersionOfManifestFileItThrows() { _fileSystem.File.WriteAllText(Path.Combine(_testDirectoryRoot, _manifestFilename), _jsonContentHigherVersion); var toolManifest = new ToolManifestFinder(new DirectoryPath(_testDirectoryRoot), _fileSystem); Action a = () => toolManifest.TryFind(new ToolCommandName("dotnetsay"), out var result); a.ShouldThrow <ToolManifestException>(); }
public void GivenManifestFileOnSameDirectoryWhenFindByCommandNameWithDifferentCasingItGetContent() { _fileSystem.File.WriteAllText(Path.Combine(_testDirectoryRoot, _manifestFilename), _jsonContent); var toolManifest = new ToolManifestFinder(new DirectoryPath(_testDirectoryRoot), _fileSystem); toolManifest.TryFind(new ToolCommandName("dotnetSay"), out var result).Should().BeTrue(); result.ShouldBeEquivalentTo(new ToolManifestPackage( new PackageId("dotnetsay"), NuGetVersion.Parse("2.1.4"), new[] { new ToolCommandName("dotnetsay") })); }
public void GivenInvalidFieldsManifestFileWhenFindByCommandNameItThrows() { _fileSystem.File.WriteAllText(Path.Combine(_testDirectoryRoot, _manifestFilename), _jsonWithInvalidField); var toolManifest = new ToolManifestFinder( new DirectoryPath(_testDirectoryRoot), _fileSystem, new FakeDangerousFileDetector()); Action a = () => toolManifest.TryFind(new ToolCommandName("dotnetSay"), out var result); a.ShouldThrow <ToolManifestException>(); }
public void GivenConflictedManifestFileInDifferentFieldsWhenFindByCommandNameItOnlyConsiderTheFirstIsRoot() { var subdirectoryOfTestRoot = Path.Combine(_testDirectoryRoot, "sub"); _fileSystem.Directory.CreateDirectory(subdirectoryOfTestRoot); _fileSystem.File.WriteAllText(Path.Combine(_testDirectoryRoot, _manifestFilename), _jsonContentInParentDirectory); _fileSystem.File.WriteAllText(Path.Combine(subdirectoryOfTestRoot, _manifestFilename), _jsonContentInCurrentDirectoryIsRootTrue); var toolManifest = new ToolManifestFinder(new DirectoryPath(subdirectoryOfTestRoot), _fileSystem); var manifestResult = toolManifest.Find(); toolManifest.TryFind(new ToolCommandName("dotnetsay2"), out var result).Should().BeFalse(); }
public void GivenManifestFileOnParentDirectoryWhenFindByCommandNameItGetContent() { var subdirectoryOfTestRoot = Path.Combine(_testDirectoryRoot, "sub"); _fileSystem.File.WriteAllText(Path.Combine(_testDirectoryRoot, _manifestFilename), _jsonContent); var toolManifest = new ToolManifestFinder(new DirectoryPath(subdirectoryOfTestRoot), _fileSystem); toolManifest.TryFind(new ToolCommandName("dotnetsay"), out var result).Should().BeTrue(); result.Should().Be(new ToolManifestPackage( new PackageId("dotnetsay"), NuGetVersion.Parse("2.1.4"), new[] { new ToolCommandName("dotnetsay") }, new DirectoryPath(_testDirectoryRoot))); }
public void GivenConflictedManifestFileInDifferentFieldsWhenFindByCommandNameItReturnMergedContent() { var subdirectoryOfTestRoot = Path.Combine(_testDirectoryRoot, "sub"); _fileSystem.Directory.CreateDirectory(subdirectoryOfTestRoot); _fileSystem.File.WriteAllText(Path.Combine(_testDirectoryRoot, _manifestFilename), _jsonContentInParentDirectory); _fileSystem.File.WriteAllText(Path.Combine(subdirectoryOfTestRoot, _manifestFilename), _jsonContentInCurrentDirectory); var toolManifest = new ToolManifestFinder(new DirectoryPath(subdirectoryOfTestRoot), _fileSystem); toolManifest.TryFind(new ToolCommandName("t-rex"), out var result).Should().BeTrue(); result.ShouldBeEquivalentTo(new ToolManifestPackage( new PackageId("t-rex"), NuGetVersion.Parse("1.0.49"), new[] { new ToolCommandName("t-rex") })); }