Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/Paket.Core/Dependencies/NuGetV2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ let private followODataLink auth url =
let mutable uri = null // warn once per specific API endpoint, but try to cut the query
let baseUrl = if Uri.TryCreate(url, UriKind.Absolute, &uri) then uri.AbsolutePath else url
traceWarnIfNotBefore baseUrl
"At least one 'next' link (index %d) returned a empty result (noticed on '%O'): ['%s']"
"At least one 'next' link (index %d) returned a empty result (noticed on '%O'): ['%s']"
i url (System.String.Join("' ; '", linksToFollow))
| None -> ()
return
Expand Down Expand Up @@ -179,10 +179,11 @@ let private handleODataEntry nugetURL packageName version entry =
| Some node -> node.InnerText
| _ -> ""

// If a package has no dependencies, JFrog Artifactory will return an XML structure without the Dependencies node.
let dependencies =
match entry |> getNode "properties" |> optGetNode "Dependencies" with
| Some node -> node.InnerText
| None -> failwithf "unable to find dependencies for package %O %O" packageName version
| None -> ""

let rawPackages =
let split (d : string) =
Expand All @@ -195,7 +196,7 @@ let private handleODataEntry nugetURL packageName version entry =
| Some p ->
Some p
| None ->
if not (restriction.StartsWith "_") then
if not (restriction.StartsWith "_") then
Logging.traceWarnIfNotBefore ("Package", restriction, packageName, version) "Could not detect any platforms from '%s' in package %O %O, please tell the package authors" restriction packageName version
None
else Some PlatformMatching.ParsedPlatformPath.Empty)
Expand Down Expand Up @@ -480,5 +481,3 @@ let FindPackages(auth, nugetURL, packageNamePrefix, maxResults) =
with e ->
return FSharp.Core.Result.Error (ExceptionDispatchInfo.Capture e)
}


44 changes: 44 additions & 0 deletions tests/Paket.Tests/NuGetOData/NoDependenciesNode.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="http://doesntmatter/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<id>http://doesntmatter/Packages(Id='NoDeps',Version='1.0.0')</id>
<category term="NuGetGallery.V2FeedPackage" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="V2FeedPackage" href="Packages(Id='NoDeps',Version='1.0.0')" />
<title type="text">NoDeps</title>
<summary type="text">Package without any dependencies, as returned by JFrog Artifactory.</summary>
<updated>2020-01-01T00:00:00Z</updated>
<author>
<name>Someone</name>
</author>
<link rel="edit-media" title="V2FeedPackage" href="Packages(Id='NoDeps',Version='1.0.0')/$value" />
<content type="application/zip" src="http://doesntmatter/package/NoDeps/1.0.0" />
<m:properties>
<d:Version>1.0.0</d:Version>
<d:NormalizedVersion>1.0.0</d:NormalizedVersion>
<d:Copyright m:null="true" />
<d:Created m:type="Edm.DateTime">2020-01-01T00:00:00.000</d:Created>
<d:Description>A package with no dependencies node in the OData response (e.g. JFrog Artifactory).</d:Description>
<d:DownloadCount m:type="Edm.Int32">0</d:DownloadCount>
<d:GalleryDetailsUrl>http://doesntmatter/packages/NoDeps/1.0.0</d:GalleryDetailsUrl>
<d:IconUrl m:null="true" />
<d:IsLatestVersion m:type="Edm.Boolean">true</d:IsLatestVersion>
<d:IsAbsoluteLatestVersion m:type="Edm.Boolean">true</d:IsAbsoluteLatestVersion>
<d:IsPrerelease m:type="Edm.Boolean">false</d:IsPrerelease>
<d:Language m:null="true" />
<d:Published m:type="Edm.DateTime">2020-01-01T00:00:00.000</d:Published>
<d:PackageHash>AAAA</d:PackageHash>
<d:PackageHashAlgorithm>SHA512</d:PackageHashAlgorithm>
<d:PackageSize m:type="Edm.Int64">1234</d:PackageSize>
<d:ProjectUrl m:null="true" />
<d:ReportAbuseUrl>http://doesntmatter/package/ReportAbuse/NoDeps/1.0.0</d:ReportAbuseUrl>
<d:ReleaseNotes m:null="true" />
<d:RequireLicenseAcceptance m:type="Edm.Boolean">false</d:RequireLicenseAcceptance>
<d:Tags></d:Tags>
<d:Title>NoDeps</d:Title>
<d:VersionDownloadCount m:type="Edm.Int32">0</d:VersionDownloadCount>
<d:MinClientVersion m:null="true" />
<d:LastEdited m:type="Edm.DateTime" m:null="true" />
<d:LicenseUrl>http://doesntmatter/license</d:LicenseUrl>
<d:LicenseNames m:null="true" />
<d:LicenseReportUrl m:null="true" />
</m:properties>
</entry>
13 changes: 13 additions & 0 deletions tests/Paket.Tests/NuGetOData/ODataSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ let ``can detect explicit dependencies for Microsoft.AspNet.WebApi.Client``() =
FrameworkRestriction.And [getPortableRestriction("portable-net45+win8+wp8+wp81+wpa81"); FrameworkRestriction.NotAtLeast(DotNetFramework(FrameworkVersion.V4_5))]
|> ExplicitRestriction)

[<Test>]
let ``can parse package without Dependencies node as no dependencies``() =
parseEntry "NuGetOData/NoDependenciesNode.xml"
|> shouldEqual
{ PackageName = "NoDeps"
DownloadUrl = "http://doesntmatter/package/NoDeps/1.0.0"
SerializedDependencies = []
Unlisted = false
LicenseUrl = "http://doesntmatter/license"
CacheVersion = NuGet.NuGetPackageCache.CurrentCacheVersion
Version = "1.0.0"
SourceUrl = fakeUrl }

[<Test>]
let ``can ignore unknown frameworks``() =
let parsed = parseList "NuGetOData/BenchmarkDotNet-UnknownFramework.xml" |> ODataSearchResult.get
Expand Down
1 change: 1 addition & 0 deletions tests/Paket.Tests/Paket.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<TestAsset Include="NuGetOData\Rx-PlatformServices.xml" />
<TestAsset Include="NuGetOData\EasyNetQ.xml" />
<TestAsset Include="NuGetOData\BenchmarkDotNet-UnknownFramework.xml" />
<TestAsset Include="NuGetOData\NoDependenciesNode.xml" />
<Compile Include="NuGetOData\ODataSpecs.fs" />
<TestAsset Include="NuGetConfig\ClearTextPasswordConfig.xml" />
<TestAsset Include="NuGetConfig\PasswordConfig.xml" />
Expand Down
Loading