protected override async Task OnExecute() { if (!String.IsNullOrEmpty(PackagesConfig)) { List <PackageConfigParser.Package> IdAndVersion = PackageConfigParser.GetIdAndVersionFromPackagesConfig(PackagesConfig); if (IdAndVersion == null) { await Console.WriteErrorLine(String.Format(Strings.Package_DeleteCommand_InvalidPackagesConfig, PackagesConfig)); } await DeleteP(IdAndVersion); return; } if (String.IsNullOrEmpty(Id) && String.IsNullOrEmpty(PackagesConfig)) { await Console.WriteErrorLine(Strings.Package_DeleteCommand_InvalidArguments); return; } if (String.IsNullOrWhiteSpace(Version) && !AllVersions) { await Console.WriteErrorLine(Strings.Package_AllVersionsRequiredIfVersionNull); return; } if (!String.IsNullOrWhiteSpace(Version) && AllVersions) { await Console.WriteErrorLine(Strings.Package_VersionAndAllVersionsSpecified); return; } PackageConfigParser.Package package = new PackageConfigParser.Package(); package.Id = Id; package.Version = Version; List <PackageConfigParser.Package> singlePackage = new List <PackageConfigParser.Package>(); singlePackage.Add(package); await DeleteP(singlePackage); }
public static void ParsePackagesConfigFileContent_ReturnsExpectedResult() { var content = Helpers.ReadEmbeddedResourceFile("packages.config.txt"); var result = PackageConfigParser.ParsePackagesConfigFileContent(content).ToArray(); Assert.That(result, Is.Not.Null); Assert.Multiple( () => { Assert.That(result.Length, Is.EqualTo(1)); Assert.That(result[0].Name, Is.EqualTo("Cake")); Assert.That(result[0].Version, Is.EqualTo("0.17.0")); // todo Do more asserts here. } ); }
internal void ProcessPackagesConfig(ProjectMetadata projectMetadata, SourceInformation projectDirectory) { _logger.Trace("Entering"); var packagesConfig = Tools.GetChildFileInformation( new SourceInformation(projectDirectory), "packages.config"); var sourceTool = GetSourceTool(); var sw = Stopwatch.StartNew(); var content = sourceTool.GetItemContent(packagesConfig); sw.Stop(); _logger.Trace($"GetItemContent took {sw.Elapsed}"); if (content != null) { projectMetadata.PackageReferences = PackageConfigParser.ParsePackagesConfigFileContent(content).ToList(); } }
public static void ParsePackagesConfigFileContent_Throws(string input) { Assert.Throws <ArgumentException>(() => PackageConfigParser.ParsePackagesConfigFileContent(input)); }