【问题标题】:Executing a Powershell Script in Fake假执行 Powershell 脚本
【发布时间】:2014-04-28 21:23:47
【问题描述】:

在 Fake 构建自动化工具中执行 Powershell 脚本的最佳方法是什么?

感觉这个问题应该有一个明显的答案,但是一直没能通过搜索找到任何东西。

【问题讨论】:

  • Fake 是一个 F# 工具,所以我想你可以使用 Process 类。
  • 听起来很像,或者使用 Powershell 主机类(见链接)。我是 F# 菜鸟 - 不考虑显而易见的事情!

标签: powershell f# f#-fake


【解决方案1】:

正如您在评论中提到的,使用 PowerShell 类使这变得非常容易。

#r "FakeLib.dll"
#r "System.Management.Automation"

open Fake
open System.Management.Automation

Target "RunSomePowerShell" <| fun _ ->
    PowerShell.Create()
      .AddScript("(Get-Process | ? ProcessName -eq 'chrome' | measure WorkingSet -Average).Average")
      .Invoke()
      |> Seq.iter (printfn "%O")

【讨论】:

    猜你喜欢
    • 2021-11-06
    • 2012-09-18
    • 2012-06-14
    • 1970-01-01
    • 2014-01-06
    • 2011-07-16
    • 2021-09-19
    • 2012-04-28
    • 2017-06-14
    相关资源
    最近更新 更多