如何抑制部分FAKE输出?

How to suppress part of FAKE output?

我有一个使用 FAKE 构建、打包并推送到 NuGet 的库。工作正常。

现在,我想通过 Travis CI 以连续模式完成所有这些工作,包括 "push" 部分。我知道存在安全问题,但似乎我可以通过将 NuGet API 密钥放入 Travis 环境变量中来安全地(至少在原则上)做到这一点,所以它是 not available to external pull requests,并且仅在建立一个特殊的专用分支。

当FAKE遇到Travis时,问题就来了。

  1. 事实证明,当我使用 Paket.Push helper 时,整个 paket.exe 命令行作为 FAKE 的输出发出,并带有我的 NuGet API 键。
  2. 同时,事实证明 Travis 允许任何未经身份验证的爱管闲事的人查看 any project 的完整构建日志。我的 NuGet API 键就在那里。

我知道我可以通过将 FAKE 重定向到 /dev/null(在 .travis.yml 中)来禁用整个输出,但我想保留 most 的输出,只需用键隐藏该特定部分。

我在 PaketPushParams structure 中找不到任何相关参数,Google 也没有找到任何东西。下一步是查看 FAKE 源代码以查看输出是否是有条件的,但我想我会先问一下。我不能成为第一个击中它的人。 :-)

我也没有找到 Google 的答案,但我或多或少知道在哪里可以查看 FAKE 源代码,所以我继续这样做了。

它看起来像 Paket.Push helper calls ExecProcess to actually run the relevant task. ExecProcess eventually calls ExecProcessWithLambdas to do the work, and the line in ExecProcessWithLambdas that prints the process name and arguments out to the FAKE log checks the enableProcessTracing variable first, and will not output the process name and arguments if that variable is false. The enableProcessTracing variable is undocumented, but mutable,所以您应该可以设置它。我自己还没有尝试过,但原则上你应该可以做到:

ProcessHelper.enableProcessTracing <- false // Logging off
// Do security-sensitive work here
ProcessHelper.enableProcessTracing <- true  // Logging back on for rest of build

这能满足您的需求吗?