Permalink
Browse files

add ability to define custom MSBuild loggers to use

  • Loading branch information...
1 parent 198ecb3 commit bc198fcb89eb34bbdf39d13de067beb260d501b9 @mexx mexx committed Mar 9, 2014
Showing with 20 additions and 12 deletions.
  1. +20 −12 src/app/FakeLib/MSBuildHelper.fs
@@ -134,6 +134,15 @@ let getAllParameters targets maxcpu nodeReuse tools verbosity fileLoggers proper
if isUnix then [ targets; tools; verbosity ] @ fileLoggers @ properties
else [ targets; maxcpu; nodeReuse; tools; verbosity ] @ fileLoggers @ properties
+let private serializeArgs args =
+ args
+ |> Seq.map (function
+ | None -> ""
+ | Some(k, v) ->
+ "/" + k + (if isNullOrEmpty v then ""
+ else ":" + v))
+ |> separated " "
+
/// [omit]
let serializeMSBuildParams (p : MSBuildParams) =
let verbosityName v =
@@ -215,27 +224,21 @@ let serializeMSBuildParams (p : MSBuildParams) =
|> sprintf "%s;")
|> String.concat "")))
- let allParameters = getAllParameters targets maxcpu nodeReuse tools verbosity fileLoggers properties
- allParameters
- |> Seq.map (function
- | None -> ""
- | Some(k, v) ->
- "/" + k + (if isNullOrEmpty v then ""
- else ":" + v))
- |> separated " "
+ getAllParameters targets maxcpu nodeReuse tools verbosity fileLoggers properties
+ |> serializeArgs
/// [omit]
let TeamCityLoggerName = typedefof<Fake.MsBuildLogger.TeamCityLogger>.FullName
/// [omit]
let ErrorLoggerName = typedefof<Fake.MsBuildLogger.ErrorLogger>.FullName
-let private errorLoggerParam =
+/// Defines the loggers to use for MSBuild task
+let mutable MSBuildLoggers =
let pathToLogger = typedefof<MSBuildParams>.Assembly.Location
[ TeamCityLoggerName; ErrorLoggerName ]
- |> List.map (fun a -> sprintf "/logger:%s,\"%s\"" a pathToLogger)
- |> fun lst -> String.Join(" ", lst)
-
+ |> List.map (fun a -> sprintf "%s,\"%s\"" a pathToLogger)
+
/// Runs a MSBuild project
/// ## Parameters
/// - `setParams` - A function that overwrites the default MsBuildParams
@@ -263,6 +266,11 @@ let build setParams project =
MSBuildDefaults
|> setParams
|> serializeMSBuildParams
+
+ let errorLoggerParam =
+ MSBuildLoggers
+ |> List.map (fun a -> Some ("logger", a))
+ |> serializeArgs
let args = toParam project + " " + args + " " + errorLoggerParam
tracefn "Building project: %s\n %s %s" project msBuildExe args

0 comments on commit bc198fc

Please sign in to comment.