F# FAKE 构建文件中的匹配字符串

Matching string in F# FAKE build file

我有一个 F# FAKE 构建文件,我想用一个参数 conf 调用它,它可以有两个值,cs 和 sk。我的批处理文件如下所示

@echo off
cls
"tools\nuget\nuget.exe" "install" "FAKE" "-OutputDirectory" "tools" "-ExcludeVersion"
"tools\FAKE\tools\Fake.exe" build.fsx conf=sk
pause

在 F# 文件中,我使用 environVar "conf" 获取参数,这工作正常。

现在我想在 F# 文件中创建一个匹配 conf 参数和 returns 字符串(在我的例子中是构建配置值)的辅助方法,所以我有

let getConfiguration conf =
   if (conf=="cs") then "Release"
   else "Release(SK)"

我收到一条奇怪的消息

build.fsx(29,71): error FS0001: The type 'string' does not support the operator '=='

我是这样使用方法的

Target "Build" (fun _ ->
    !! @"**/*.csproj"
      |> MSBuild buildDir "Build" ["Configuration",(getConfiguration (environVar "conf"))]
      |> Log "AppBuild-Output: "
)

F# 相等运算符是 =

我不知道 FAKE 或您的方法是否有效,但编译器错误的原因是,如错误消息所述,没有 == 运算符。有效版本:

    if conf = "cs" then "Release" else "Release(SK)"

参见例如symbol and operator reference in the MSDN.