Example #1
0
        private static string GetNugetCacheDirectory(string packageId, string version)
        {
            SoupDiscoverException.ThrowIfNullOrEmpty(packageId, $"{nameof(packageId)} must be not null or empty!");
            SoupDiscoverException.ThrowIfNullOrEmpty(version, $"{nameof(version)} must be not null or empty!");
            var packageDirectory = $"{packageId}.{version}";

            return(Path.Combine(NugetCacheDirectory, packageId, version, $"{packageId}.nuspec").ToLower(CultureInfo.InvariantCulture));
        }
Example #2
0
        /// <summary>
        /// Retrieve metadata of the package, in cache, in directory %userprofile%/.nuget/packages
        /// </summary>
        /// <returns>The Xml node of the nuspec file of the package</returns>
        private static XElement GetPackageMetadataOnLocalCache(string packageId, string version)
        {
            SoupDiscoverException.ThrowIfNullOrEmpty(packageId, $"{nameof(packageId)} must be not null or empty!");
            SoupDiscoverException.ThrowIfNullOrEmpty(version, $"{nameof(version)} must be not null or empty!");
            var packageDirectory = GetNugetCacheDirectory(packageId, version);

            if (!File.Exists(packageDirectory))
            {
                return(null); // package not found in cache
            }
            var nuspecFile = XDocument.Load(packageDirectory);

            return(nuspecFile.Root.Element(XName.Get("metadata", nuspecFile.Root.Name.NamespaceName)));
        }