public static List <PackageUpdateSet> OnePackageUpdateSet() { var package = PackageVersionRange.Parse("foo.bar", "1.2.3"); return(new List <PackageUpdateSet> { UpdateSetFor(package, MakePackageForV110(package)) }); }
public void ParseableButNotToPackageIdentity(string rangeString) { var rangeIdentity = PackageVersionRange.Parse("testPackage", rangeString); var singleVersion = rangeIdentity.SingleVersionIdentity(); Assert.That(rangeIdentity, Is.Not.Null); Assert.That(rangeIdentity.Id, Is.EqualTo("testPackage")); Assert.That(rangeIdentity.Version, Is.Not.Null); Assert.That(singleVersion, Is.Null); }
internal static List <PackageUpdateSet> PackageUpdateSets(int count) { var result = new List <PackageUpdateSet>(); foreach (var index in Enumerable.Range(1, count)) { var package = PackageVersionRange.Parse( $"test.package{index}", $"1.2.{index}"); var updateSet = UpdateSetFor(package, MakePackageForV110(package)); result.Add(updateSet); } return(result); }
public static PackageUpdateSet MakeUpdateSet(string packageName, string version = "1.2.3", PackageReferenceType packageRefType = PackageReferenceType.ProjectFile) { var packageId = PackageVersionRange.Parse(packageName, version); var latest = new PackageSearchMedatadata( packageId.SingleVersionIdentity(), OfficialPackageSource(), null, Enumerable.Empty <PackageDependency>()); var packages = new PackageLookupResult(VersionChange.Major, latest, null, null); var pip = new PackageInProject(packageId, MakePackagePath(packageRefType), null) .InList(); return(new PackageUpdateSet(packages, pip)); }
private static PackageInProject PackageFor(string packageId, string packageVersion, string relativePath, PackageInProject refProject = null) { relativePath = relativePath.Replace("{sep}", $"{Path.DirectorySeparatorChar}", StringComparison.OrdinalIgnoreCase); var basePath = "c_temp" + Path.DirectorySeparatorChar + "test"; var refs = new List <string>(); if (refProject != null) { refs.Add(refProject.Path.FullName); } var packageVersionRange = PackageVersionRange.Parse(packageId, packageVersion); return(new PackageInProject(packageVersionRange, new PackagePath(basePath, relativePath, PackageReferenceType.ProjectFile), refs)); }
public PackageInProject?Read( string?id, string?version, PackagePath path, IEnumerable <string>?projectReferences) { if (path == null) { return(null); } if (string.IsNullOrWhiteSpace(id)) { _logger.Normal($"Skipping package with no id specified in file '{path.FullName}'."); return(null); } if (string.IsNullOrWhiteSpace(version)) { _logger.Normal($"Skipping package '{id}' with no version specified in file '{path.FullName}'."); return(null); } var packageVersionRange = PackageVersionRange.Parse(id, version); if (packageVersionRange == null) { _logger.Normal($"Skipping package '{id}' with version '{version}' that could not be parsed in file '{path.FullName}'."); return(null); } var pip = new PackageInProject(packageVersionRange, path, projectReferences); var singleVersion = pip.Identity; if (singleVersion == null) { _logger.Normal($"Skipping package '{id}' with version range '{version}' that is not a single version in file '{path.FullName}'."); return(null); } return(pip); }
public void TwoRowsHaveOutput() { var package1 = PackageVersionRange.Parse("foo.bar", "1.2.3"); var package2 = PackageVersionRange.Parse("fish", "2.3.4"); var rows = new List <PackageUpdateSet> { PackageUpdates.UpdateSetFor(package1, PackageUpdates.MakePackageForV110(package1)), PackageUpdates.UpdateSetFor(package2, PackageUpdates.MakePackageForV110(package2)) }; var output = ReportToString(rows); Assert.That(output, Is.Not.Null); Assert.That(output, Is.Not.Empty); var lines = output.Split(Environment.NewLine); Assert.That(lines.Length, Is.EqualTo(3)); Assert.That(lines[1], Does.Contain("foo.bar,")); Assert.That(lines[2], Does.Contain("fish,")); }
public PackageInProject Read( string id, string version, PackagePath path, IEnumerable <string> projectReferences) { if (string.IsNullOrWhiteSpace(id)) { _logger.Normal($"Skipping package with no id specified in file '{path.FullName}'."); return(null); } if (string.IsNullOrWhiteSpace(version)) { // TODO this is very spammy when using MSBuild Directory.build.props or .targets files for versioning NuGets. Should find a better way for this. _logger.Detailed($"Skipping package '{id}' with no version specified in file '{path.FullName}'."); return(null); } var packageVersionRange = PackageVersionRange.Parse(id, version); if (packageVersionRange == null) { _logger.Normal($"Skipping package '{id}' with version '{version}' that could not be parsed in file '{path.FullName}'."); return(null); } var pip = new PackageInProject(packageVersionRange, path, projectReferences); var singleVersion = pip.Identity; if (singleVersion == null) { _logger.Normal($"Skipping package '{id}' with version range '{version}' that is not a single version in file '{path.FullName}'."); return(null); } return(pip); }