F# Make - 使用 PreRelease 选项恢复某些 Nuget 包

F# Make - Restore certain Nuget packages with PreRelease option

为了指定额外的公司内部 Nuget 提要,我目前正在使用 RestorePackages 这样的:

let RestorePackages() =
    !! "./**/packages.config"
    |> Seq.iter (RestorePackage(fun p -> {p with Sources = "http://internal.example.com/nuget" :: p.Sources}))

效果很好。如何获取脚本以恢复设置了 IncludePreRelease 选项的某些包?

我试过这样匹配包裹:

let RestorePackages() =
    !! "./**/packages.config"
    |> Seq.iter (fun item ->
        match item with
        | "Example" -> RestorePackageId(fun p -> {p with IncludePreRelease = true}) "Example"
        | item -> RestorePackage(fun p -> {p with Sources = "http://internal.example.com/nuget" :: p.Sources}))

但这不起作用。调用 RestorePackage 的默认匹配表示 "This expression was expected to have type unit but here has type string -> unit".

您似乎在最后一行代码的末尾缺少一个字符串。我认为你应该在那里传递 item 变量。

    let RestorePackages() =
        !! "./**/packages.config"
        |> Seq.iter (fun item ->
            match item with
            | "Example" -> RestorePackageId(fun p -> {p with IncludePreRelease = true}) "Example"
            | item -> RestorePackage(fun p -> {p with Sources = "http://internal.example.com/nuget" :: p.Sources}) item)