private static async Task <bool> CheckDevelopmentDependencyAsync( DownloadResourceResult downloadResourceResult, CancellationToken token) { var isDevelopmentDependency = false; // Catch any exceptions while fetching DevelopmentDependency element from nuspec file. // So it can continue to write the packages.config file. try { if (downloadResourceResult.PackageReader != null) { isDevelopmentDependency = await downloadResourceResult.PackageReader.GetDevelopmentDependencyAsync(token); } else { using (var packageReader = new PackageArchiveReader( downloadResourceResult.PackageStream, leaveStreamOpen: true)) { var nuspecReader = new NuspecReader(packageReader.GetNuspec()); isDevelopmentDependency = nuspecReader.GetDevelopmentDependency(); } } } catch { } return(isDevelopmentDependency); }
public static void UpdatePackageReferenceMetadata( PackageSpec packageSpec, FallbackPackagePathResolver pathResolver, PackageIdentity package) { var info = pathResolver.GetPackageInfo(package.Id, package.Version); var nuspecFilePath = info?.PathResolver.GetManifestFilePath(package.Id, package.Version); var nuspecReader = new NuspecReader(nuspecFilePath); var developmentDependency = nuspecReader.GetDevelopmentDependency(); if (developmentDependency) { foreach (var frameworkInfo in packageSpec.TargetFrameworks .OrderBy(framework => framework.FrameworkName.ToString(), StringComparer.Ordinal)) { var dependency = frameworkInfo.Dependencies.First(dep => dep.Name.Equals(package.Id, StringComparison.OrdinalIgnoreCase)); if (dependency?.SuppressParent == LibraryIncludeFlagUtils.DefaultSuppressParent && dependency?.IncludeType == LibraryIncludeFlags.All) { dependency.SuppressParent = LibraryIncludeFlags.All; dependency.IncludeType = LibraryIncludeFlags.All & ~LibraryIncludeFlags.Runtime; } } } }
public static void UpdatePackageReferenceMetadata( LockFile lockFile, FallbackPackagePathResolver pathResolver, PackageIdentity package) { var info = pathResolver.GetPackageInfo(package.Id, package.Version); if (info == null) { // don't do anything if package was not resolved on disk return; } var nuspecFilePath = info.PathResolver.GetManifestFilePath(package.Id, package.Version); var nuspecReader = new NuspecReader(nuspecFilePath); var developmentDependency = nuspecReader.GetDevelopmentDependency(); if (developmentDependency) { foreach (var frameworkInfo in lockFile.PackageSpec.TargetFrameworks .OrderBy(framework => framework.FrameworkName.ToString(), StringComparer.Ordinal)) { var dependency = frameworkInfo.Dependencies.First(dep => dep.Name.Equals(package.Id, StringComparison.OrdinalIgnoreCase)); if (dependency?.SuppressParent == LibraryIncludeFlagUtils.DefaultSuppressParent && dependency?.IncludeType == LibraryIncludeFlags.All) { var includeType = LibraryIncludeFlags.All & ~LibraryIncludeFlags.Compile; dependency.SuppressParent = LibraryIncludeFlags.All; dependency.IncludeType = includeType; // update lock file target libraries foreach (var target in lockFile.Targets .Where(t => EqualityUtility.EqualsWithNullCheck(t.TargetFramework, frameworkInfo.FrameworkName))) { var targetLibrary = target.GetTargetLibrary(package.Id); if (targetLibrary != null) { LockFileUtils.ExcludeItems(targetLibrary, includeType); } } } } } }
public ServerPackage(NuspecReader package, PackageDerivedData packageDerivedData) { Id = package.GetId(); Version = package.GetVersion(); Title = package.GetTitle(); Authors = package.GetAuthors(); Owners = package.GetOwners(); IconUrl = package.GetIconUrl(); LicenseUrl = package.GetLicenseUrl(); ProjectUrl = package.GetProjectUrl(); RequireLicenseAcceptance = package.GetRequireLicenseAcceptance(); DevelopmentDependency = package.GetDevelopmentDependency(); Description = package.GetDescription(); Summary = package.GetSummary(); ReleaseNotes = package.GetReleaseNotes(); Language = package.GetLanguage(); Tags = package.GetTags(); Copyright = package.GetCopyright(); MinClientVersion = package.GetMinClientVersion(); ReportAbuseUrl = null; DownloadCount = 0; SemVer1IsAbsoluteLatest = false; SemVer1IsLatest = false; SemVer2IsAbsoluteLatest = false; SemVer2IsLatest = false; //FIXME is this OK? Listed = true; IsSemVer2 = IsPackageSemVer2(package); _dependencySets = package.GetDependencyGroups().ToList(); Dependencies = _dependencySets.DependencySetsAsString(); _supportedFrameworks = package.GetFrameworkReferenceGroups().Select(f => f.TargetFramework).ToList(); SupportedFrameworks = string.Join("|", _supportedFrameworks.Select(f => f.GetFrameworkString())); PackageSize = packageDerivedData.PackageSize; PackageHash = packageDerivedData.PackageHash; PackageHashAlgorithm = packageDerivedData.PackageHashAlgorithm; LastUpdated = packageDerivedData.LastUpdated; Created = packageDerivedData.Created; Path = packageDerivedData.Path; FullPath = packageDerivedData.FullPath; }
protected override bool ReadMetadata(NuspecReader reader) { return(reader.GetDevelopmentDependency()); }