缩小MSBuild的详细程度以限制虚假构建输出

时间:2017-01-22 20:45:39

标签: msbuild f#-fake

如何限制假构建中MSBuild任务生成的输出? 我对看到所有编译信息细节并不感兴趣,因为我有兴趣看到警告信息。

我开始使用StyleCop.Analyzers,如果我收到一条警告,很难在构建任务生成的所有消息中观察到。

以下是我现在的方式:

// Target Build Application
Target "BuildApp" (fun _ ->
    MSBuildRelease buildDir "Build" appReferences
    |> Log "AppBuild-Output: "
)

1 个答案:

答案 0 :(得分:1)

MSBuild助手中最常用的辅助函数是MSBuildHelper.build。所有其他功能都是它的特化。

此函数采用setParams函数,该函数遵循一般的FAKE模式:采用默认参数结构并以某种方式修改它。要设置日志详细程度,请使用MSBuildParameters.Verbosity字段:

Target "BuildApp" (fun _ -> 
    "Project.sln"
    |> MSBuildHelper.build (fun p ->
        { p with
             Properties = [ "OutputPath", buildDir ]
             Verbosity = Some Minimal
             Targets = [ "Build" ] } ) )

或者,您可以通过修改MSBuildDefaults结构来设置整个构建的详细程度:

MSBuildDefaults <- { MSBuildDefaults with Verbosity = Some Minimal }

这样,所有MSBuild调用都将使用最小的详细程度。