Cake Task output log to file

北慕城南 提交于 2019-12-24 14:09:22

问题


I have a set of Tasks inside a build.cake file and I would like to capture the log output from the console into a log file. I know it's possible to use the OnError() function to output errors to file but I would like to output everything to a log file, not just errors. Below is an example of the build.cake file.

#load "SomeTask.cake"
#load "SomeOtherTask.cake"

var target = Argument("target", "Default");

var someTask = Task("SomeTask")
.Does(() =>
{
     SomeMethodInsideSomeTask();
});

var someOtherTask = Task("SomeOtherTask")
.Does(() => 
{
    SomeOtherMethodInsideSomeOtherTask();
});

Task("Default")
.IsDependentOn(someTask)
.IsDependentOn(someOtherTask);

RunTarget(target);

N.B. The Tasks are not running any sort of MSBuild commands so it's not possible to use MSBuildFileLogger.


回答1:


How about pipe the stdout to a file i.e.

./build.ps1 > log.txt




回答2:


Have you heard about tee ? It reads standard input and writes it to both standard output and one or more files



来源:https://stackoverflow.com/questions/51073127/cake-task-output-log-to-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!