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: 8 additions & 1 deletion src/Paket.Core/Dependencies/NuGetCache.fs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,14 @@ let tryGetDetailsFromCache force nugetURL (packageName:PackageName) (version:Sem
None

/// Reads packageName and version from .nupkg file name
let parsePackageInfoFromFileName fileName : (PackageName * SemVerInfo) option =
let parsePackageInfoFromFileName (fileName:string) : (PackageName * SemVerInfo) option =
// Symbol packages are named "<name>.<version>.symbols.nupkg" - strip the ".symbols"
// suffix before parsing so symbol-only local feeds are still recognized.
let fileName =
if fileName.EndsWith(".symbols.nupkg", StringComparison.OrdinalIgnoreCase) then
fileName.Substring(0, fileName.Length - ".symbols.nupkg".Length) + ".nupkg"
else
fileName
let regex = Regex ("^(?<name>.*?)\.(?<version>\d.*)\.nupkg$", RegexOptions.IgnoreCase)
match regex.Match fileName with
| matchResult when matchResult.Success && matchResult.Groups.Count = 3 ->
Expand Down
10 changes: 8 additions & 2 deletions src/Paket.Core/Dependencies/NuGetLocal.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ let getAllVersionsFromLocalPath (isCache, localNugetPath, package:PackageName, a

let versions =
Directory.EnumerateFiles(di.FullName,"*.nupkg",SearchOption.AllDirectories)
|> Seq.filter (fun fi -> fi.EndsWith ".symbols.nupkg" |> not)
|> Seq.choose (fun fileName ->
let fi = FileInfo(fileName)
let _match = Regex(sprintf @"^%O\.(\d.*)\.nupkg" package, RegexOptions.IgnoreCase).Match(fi.Name)
// Symbol packages are named "<name>.<version>.symbols.nupkg" - strip the
// ".symbols" suffix before matching so symbol-only local feeds still resolve.
let name =
if fi.Name.EndsWith(".symbols.nupkg", StringComparison.OrdinalIgnoreCase) then
fi.Name.Substring(0, fi.Name.Length - ".symbols.nupkg".Length) + ".nupkg"
else
fi.Name
let _match = Regex(sprintf @"^%O\.(\d.*)\.nupkg" package, RegexOptions.IgnoreCase).Match(name)
if _match.Groups.Count > 1 then Some _match.Groups.[1].Value else None)
|> Seq.toArray
return SuccessResponse(versions)
Expand Down
2 changes: 2 additions & 0 deletions tests/Paket.Tests/NuGetLocal/NuGetLocalSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ let ``package file name split to id and version correctly``() =
"package.name.with.dots.1.2.3-alpha2.nupkg", Some (PackageName "package.name.with.dots", SemVer.Parse "1.2.3-alpha2")
"package.1.2.3.nupkg.back", None
"package.name.without.version.nupkg", None
"package.1.2.3.symbols.nupkg", Some (PackageName "package", SemVer.Parse "1.2.3")
"package.name.with.dots.1.2.3-alpha2.symbols.nupkg", Some (PackageName "package.name.with.dots", SemVer.Parse "1.2.3-alpha2")
]
|> List.iter
(fun (input, expectedResult) ->
Expand Down
Loading