Executing a Powershell Script in Fake

2019-02-16 17:13发布

问题:

What is the best way to go about executing a Powershell script in the Fake build automation tool ?

I feel that there should be an obvious answer to this question, but have not been able to find anything by searching.

回答1:

As you mention in your comment, using the PowerShell class makes this very easy.

#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")