【发布时间】:2015-09-15 16:31:11
【问题描述】:
我想使用 FAKE 自动化我的项目的构建过程,这需要我运行一个 grunt 任务。
特别是,我想在解决方案文件夹的子文件夹中创建一个运行 grunt 构建任务的目标。由于缺乏 F# 知识,我无法将多个参数传递给 Shell 类的静态 Exec 方法。 https://fsharp.github.io/FAKE/apidocs/fake-processhelper-shell.html
这是我目前得到的:
Target "RunGrunt" (fun _ ->
let errorCode = Shell.Exec "grunt" "build" "\Frontend"
()
)
此操作失败并显示以下错误消息:
build.fsx(38,23): error FS0003: This value is not a function and cannot be applied
如果我删除最后 2 个参数,它可以工作,但在运行时找不到 grunt:
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Fake.ProcessHelper.start(Process proc) in C:\code\fake\src\app\FakeLib\ProcessHelper.fs:line 22
at Fake.ProcessHelper.asyncShellExec@424-2.Invoke(Process _arg1) in C:\code\fake\src\app\FakeLib\ProcessHelper.fs:line 428
at Microsoft.FSharp.Control.AsyncBuilderImpl.callA@851.Invoke(AsyncParams`1 args)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.FSharp.Control.AsyncBuilderImpl.commit[a](Result`1 res)
at Microsoft.FSharp.Control.CancellationTokenOps.RunSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout)
at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken)
at FSI_0001.Build.clo@34-6.Invoke(Unit _arg5) in D:\Development\Repos\FMVEAv2\Fmvea2-frontend\build.fsx:line 36
at Fake.TargetHelper.runSingleTarget(TargetTemplate`1 target) in C:\code\fake\src\app\FakeLib\TargetHelper.fs:line 483
Grunt 包含在路径变量中。 (如果从命令行调用它会起作用)
我的问题是:
如何将多个参数传递给 Shell.Exec 方法?
如何在不包含完整路径的情况下运行 grunt?
【问题讨论】:
-
我认为元组形式而不是咖喱形式 -
Shell.Exec( "grunt","build","\FrontEnd") -
好的,这解决了第一个问题,谢谢 :) 对第二个问题有什么建议吗?