let private tryFindFileWithExt (dir: string) (ext: string) =
IO.Directory.GetFiles(dir) |> Seq.tryPick (fun path ->
if path.EndsWith(ext)
then Some(dir </> path)
else None)
let private findFileWithExt (dir: string) (ext: string) =
tryFindFileWithExt dir ext
|> function
| Some x -> x
| None -> failwithf "Cannot find %s in %s" ext dir
// Looks like the `nuget push` command automatically detects the .snupkg symbols
// We issue the command below just in case but with --skip-duplicate to prevent errors
tryFindFileWithExt tempDir ".snupkg"
|> function
| Some snupkg ->
runList ["dotnet nuget push"; snupkg; "-s nuget.org --skip-duplicate -k"; nugetKey]
| None ->
printfn "No .snupkg found - ignoring"
Refactored findFileWithExt to create tryFindFileWithExt
Used tryFindFileWithExt to prevent exception when no .snupkg exists, causing a reported failure of the operation, having already pushed the .nupkg successfully.
I have a fix for handling missing .snupkg files, but get a 404 for the registered URL at https://www.npmjs.com/package/fable-publish-utils
Missing URL https://github.com/fable-compiler/fable-publish-utils
Code:
findFileWithExt
to createtryFindFileWithExt
tryFindFileWithExt
to prevent exception when no .snupkg exists, causing a reported failure of the operation, having already pushed the.nupkg
successfully.