Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #352 from mexx/custom-msbuild-loggers

Add ability to define custom MSBuild loggers
  • Loading branch information...
commit 8efc3068bcfae4265c0c22a4b56b96b4ae56376c 2 parents 73aea42 + bc198fc
@forki forki authored
Showing with 21 additions and 13 deletions.
  1. +20 −12 src/app/FakeLib/MSBuildHelper.fs
  2. +1 −1  src/app/FakeLib/MsBuildLogger.fs
View
32 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,14 +224,8 @@ 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
@@ -230,12 +233,12 @@ 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
View
2  src/app/FakeLib/MsBuildLogger.fs
@@ -16,7 +16,7 @@ type MSBuildLogger() =
let mutable Verbosity = LoggerVerbosity.Normal
let mutable Parameters = ""
- /// Abstract fucntion which registers a event listener.
+ /// Abstract function which registers an event listener.
abstract RegisterEvents : IEventSource -> unit
override t.RegisterEvents e = ()
Please sign in to comment.
Something went wrong with that request. Please try again.