From d24564d773b6bcf71d61fc266b268f0e82c3d006 Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Wed, 3 Sep 2014 17:42:24 -0500 Subject: [PATCH 1/3] first pass at adding distributed file logger support made the logger stringification common. --- src/app/FakeLib/MSBuildHelper.fs | 104 +++++++++++++++++-------------- 1 file changed, 58 insertions(+), 46 deletions(-) diff --git a/src/app/FakeLib/MSBuildHelper.fs b/src/app/FakeLib/MSBuildHelper.fs index e81de03dd45..05d6212ae23 100644 --- a/src/app/FakeLib/MSBuildHelper.fs +++ b/src/app/FakeLib/MSBuildHelper.fs @@ -3,10 +3,8 @@ module Fake.MSBuildHelper open System -open System.Text open System.IO open System.Configuration -open System.Xml open System.Xml.Linq /// An type to represent MSBuild project files. @@ -122,7 +120,8 @@ type MSBuildParams = ToolsVersion : string option Verbosity : MSBuildVerbosity option NoConsoleLogger : bool - FileLoggers : MSBuildFileLoggerConfig list option } + FileLoggers : MSBuildFileLoggerConfig list option + DistributedLoggers : (MSBuildFileLoggerConfig * MSBuildFileLoggerConfig option) list option } /// Defines a default for MSBuild task parameters let mutable MSBuildDefaults = @@ -133,12 +132,13 @@ let mutable MSBuildDefaults = ToolsVersion = None Verbosity = None NoConsoleLogger = false - FileLoggers = None } + FileLoggers = None + DistributedLoggers = None } /// [omit] -let getAllParameters targets maxcpu nodeReuse tools verbosity noconsolelogger fileLoggers properties = - if isUnix then [ targets; tools; verbosity; noconsolelogger ] @ fileLoggers @ properties - else [ targets; maxcpu; nodeReuse; tools; verbosity; noconsolelogger ] @ fileLoggers @ properties +let getAllParameters targets maxcpu nodeReuse tools verbosity noconsolelogger fileLoggers distributedFileLoggers properties = + if isUnix then [ targets; tools; verbosity; noconsolelogger ] @ fileLoggers @ distributedFileLoggers @ properties + else [ targets; maxcpu; nodeReuse; tools; verbosity; noconsolelogger ] @ fileLoggers @ distributedFileLoggers @ properties let private serializeArgs args = args @@ -150,7 +150,7 @@ let private serializeArgs args = |> separated " " /// [omit] -let serializeMSBuildParams (p : MSBuildParams) = +let serializeMSBuildParams (p : MSBuildParams) = let verbosityName v = match v with | Quiet -> "q" @@ -158,6 +158,38 @@ let serializeMSBuildParams (p : MSBuildParams) = | Normal -> "n" | Detailed -> "d" | Diagnostic -> "diag" + + let serializeLogger fl = + let logParams param = + match param with + | Append -> "Append" + | PerformanceSummary -> "PerformanceSummary" + | Summary -> "Summary" + | NoSummary -> "NoSummary" + | ErrorsOnly -> "ErrorsOnly" + | WarningsOnly -> "WarningsOnly" + | NoItemAndPropertyList -> "NoItemAndPropertyList" + | ShowCommandLine -> "ShowCommandLine" + | ShowTimestamp -> "ShowTimestamp" + | ShowEventId -> "ShowEventId" + | ForceNoAlign -> "ForceNoAlign" + | DisableConsoleColor -> "DisableConsoleColor" + | DisableMPLogging -> "DisableMPLogging" + | EnableMPLogging -> "EnableMPLogging" + + sprintf "%s%s%s" + (match fl.Filename with + | None -> "" + | Some f -> sprintf "logfile=%s;" f) + (match fl.Verbosity with + | None -> "" + | Some v -> sprintf "Verbosity=%s;" (verbosityName v)) + (match fl.Parameters with + | None -> "" + | Some ps -> + ps + |> List.map (fun p -> sprintf "%s;" (logParams p)) + |> String.concat "") let targets = match p.Targets with @@ -194,45 +226,25 @@ let serializeMSBuildParams (p : MSBuildParams) = else None let fileLoggers = - let logParams param = - match param with - | Append -> "Append" - | PerformanceSummary -> "PerformanceSummary" - | Summary -> "Summary" - | NoSummary -> "NoSummary" - | ErrorsOnly -> "ErrorsOnly" - | WarningsOnly -> "WarningsOnly" - | NoItemAndPropertyList -> "NoItemAndPropertyList" - | ShowCommandLine -> "ShowCommandLine" - | ShowTimestamp -> "ShowTimestamp" - | ShowEventId -> "ShowEventId" - | ForceNoAlign -> "ForceNoAlign" - | DisableConsoleColor -> "DisableConsoleColor" - | DisableMPLogging -> "DisableMPLogging" - | EnableMPLogging -> "EnableMPLogging" match p.FileLoggers with | None -> [] | Some fls -> fls - |> List.map - (fun fl -> - Some - ("flp" + (string fl.Number), - sprintf "%s%s%s" - (match fl.Filename with - | None -> "" - | Some f -> sprintf "logfile=%s;" f) - (match fl.Verbosity with - | None -> "" - | Some v -> sprintf "Verbosity=%s;" (verbosityName v)) - (match fl.Parameters with - | None -> "" - | Some ps -> - ps - |> List.map (fun p -> sprintf "%s;" (logParams p)) - |> String.concat ""))) - - getAllParameters targets maxcpu nodeReuse tools verbosity noconsolelogger fileLoggers properties + |> List.map (fun fl -> Some ("flp" + (string fl.Number), serializeLogger fl) ) + + let distributedFileLoggers = + let createLoggerString cl fl = + match fl with + | None -> serializeLogger cl + | Some l -> sprintf "%s*%s" (serializeLogger cl) (serializeLogger l) + + match p.DistributedLoggers with + | None -> [] + | Some dfls -> + dfls + |> List.map(fun (cl, fl) -> Some("dl", createLoggerString cl fl)) + + getAllParameters targets maxcpu nodeReuse tools verbosity noconsolelogger fileLoggers distributedFileLoggers properties |> serializeArgs /// [omit] @@ -252,7 +264,7 @@ let mutable MSBuildLoggers = match buildServer with | BuildServer.AppVeyor -> MSBuildLoggers <- @"""C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll""" :: MSBuildLoggers -| BuildServer.TeamCity -> MSBuildLoggers <- sprintf "%s,\"%s\"" TeamCityLoggerName pathToLogger :: MSBuildLoggers +| BuildServer.TeamCity -> MSBuildLoggers <- sprintf "%s,\"%s\"" TeamCityLoggerName pathToLogger :: MSBuildLoggers | _ -> () /// Runs a MSBuild project @@ -395,8 +407,8 @@ let BuildWebsite outputPath projectFile = let projectDir = (fileInfo projectFile).Directory.FullName let mutable prefix = "" let diff = slashes projectDir - slashes currentDir - for i in 1..diff do - prefix <- prefix + "../" + prefix <- prefix + (String.replicate diff "../") + MSBuildDebug "" "Rebuild" [ projectFile ] |> ignore MSBuild "" "_CopyWebApplication;_BuiltWebOutputGroupOutput" [ "OutDir", prefix + outputPath From 8ed5ea1a32fdaae42f6df50ecae39dfcf8d920f3 Mon Sep 17 00:00:00 2001 From: Chester Husk III Date: Thu, 4 Sep 2014 12:26:59 -0500 Subject: [PATCH 2/3] tweak the distributed logger string generation some tested via my own test fsx --- src/app/FakeLib/MSBuildHelper.fs | 87 +++++++++++++++++++------------- src/test/testscripts/test1.fsx | 36 ++++++++++--- 2 files changed, 81 insertions(+), 42 deletions(-) diff --git a/src/app/FakeLib/MSBuildHelper.fs b/src/app/FakeLib/MSBuildHelper.fs index 05d6212ae23..2ab066d70f4 100644 --- a/src/app/FakeLib/MSBuildHelper.fs +++ b/src/app/FakeLib/MSBuildHelper.fs @@ -111,6 +111,12 @@ type MSBuildFileLoggerConfig = Verbosity : MSBuildVerbosity option Parameters : MSBuildLogParameter list option } +type MSBuildDistributedLoggerConfig = + { + ClassName : string option + AssemblyPath : string + Parameters : (string * string) list option } + /// A type for MSBuild task parameters type MSBuildParams = { Targets : string list @@ -121,7 +127,7 @@ type MSBuildParams = Verbosity : MSBuildVerbosity option NoConsoleLogger : bool FileLoggers : MSBuildFileLoggerConfig list option - DistributedLoggers : (MSBuildFileLoggerConfig * MSBuildFileLoggerConfig option) list option } + DistributedLoggers : (MSBuildDistributedLoggerConfig * MSBuildDistributedLoggerConfig option) list option } /// Defines a default for MSBuild task parameters let mutable MSBuildDefaults = @@ -159,37 +165,7 @@ let serializeMSBuildParams (p : MSBuildParams) = | Detailed -> "d" | Diagnostic -> "diag" - let serializeLogger fl = - let logParams param = - match param with - | Append -> "Append" - | PerformanceSummary -> "PerformanceSummary" - | Summary -> "Summary" - | NoSummary -> "NoSummary" - | ErrorsOnly -> "ErrorsOnly" - | WarningsOnly -> "WarningsOnly" - | NoItemAndPropertyList -> "NoItemAndPropertyList" - | ShowCommandLine -> "ShowCommandLine" - | ShowTimestamp -> "ShowTimestamp" - | ShowEventId -> "ShowEventId" - | ForceNoAlign -> "ForceNoAlign" - | DisableConsoleColor -> "DisableConsoleColor" - | DisableMPLogging -> "DisableMPLogging" - | EnableMPLogging -> "EnableMPLogging" - - sprintf "%s%s%s" - (match fl.Filename with - | None -> "" - | Some f -> sprintf "logfile=%s;" f) - (match fl.Verbosity with - | None -> "" - | Some v -> sprintf "Verbosity=%s;" (verbosityName v)) - (match fl.Parameters with - | None -> "" - | Some ps -> - ps - |> List.map (fun p -> sprintf "%s;" (logParams p)) - |> String.concat "") + let targets = match p.Targets with @@ -226,6 +202,38 @@ let serializeMSBuildParams (p : MSBuildParams) = else None let fileLoggers = + let serializeLogger fl = + let logParams param = + match param with + | Append -> "Append" + | PerformanceSummary -> "PerformanceSummary" + | Summary -> "Summary" + | NoSummary -> "NoSummary" + | ErrorsOnly -> "ErrorsOnly" + | WarningsOnly -> "WarningsOnly" + | NoItemAndPropertyList -> "NoItemAndPropertyList" + | ShowCommandLine -> "ShowCommandLine" + | ShowTimestamp -> "ShowTimestamp" + | ShowEventId -> "ShowEventId" + | ForceNoAlign -> "ForceNoAlign" + | DisableConsoleColor -> "DisableConsoleColor" + | DisableMPLogging -> "DisableMPLogging" + | EnableMPLogging -> "EnableMPLogging" + + sprintf "%s%s%s" + (match fl.Filename with + | None -> "" + | Some f -> sprintf "logfile=%s;" f) + (match fl.Verbosity with + | None -> "" + | Some v -> sprintf "Verbosity=%s;" (verbosityName v)) + (match fl.Parameters with + | None -> "" + | Some ps -> + ps + |> List.map (fun p -> sprintf "%s;" (logParams p)) + |> String.concat "") + match p.FileLoggers with | None -> [] | Some fls -> @@ -233,10 +241,21 @@ let serializeMSBuildParams (p : MSBuildParams) = |> List.map (fun fl -> Some ("flp" + (string fl.Number), serializeLogger fl) ) let distributedFileLoggers = + let serializeDLogger (dlogger : MSBuildDistributedLoggerConfig) = + sprintf "%s%s%s" + (match dlogger.ClassName with | None -> "" | Some name -> sprintf "%s," name) + (sprintf "\"%s\"" dlogger.AssemblyPath) + (match dlogger.Parameters with + | None -> "" + | Some vars -> vars + |> List.fold (fun acc (k,v) -> sprintf "%s%s=%s," acc k v) "" + |> sprintf ";\"%s;\"" + ) + let createLoggerString cl fl = match fl with - | None -> serializeLogger cl - | Some l -> sprintf "%s*%s" (serializeLogger cl) (serializeLogger l) + | None -> serializeDLogger cl + | Some l -> sprintf "%s*%s" (serializeDLogger cl) (serializeDLogger l) match p.DistributedLoggers with | None -> [] diff --git a/src/test/testscripts/test1.fsx b/src/test/testscripts/test1.fsx index 436ee1ec006..c4f1009e33e 100644 --- a/src/test/testscripts/test1.fsx +++ b/src/test/testscripts/test1.fsx @@ -2,11 +2,31 @@ open Fake -#if MONO -failwith "mono was set" -#else -failwith "mono was not set" -#endif - -if hasBuildParam "test" |> not then - failwith "test param is missing" +Target "blah" (fun _ -> + let simpleConfig = { + ClassName = None + AssemblyPath = "test.dll" + Parameters = None + } + + let nameConfig = {simpleConfig with ClassName = Some "simpleClass"} + let simpleWithParams = {simpleConfig with Parameters = Some [("Verbosity", "High")]} + let fullConfig = {simpleConfig with + ClassName = nameConfig.ClassName + Parameters = simpleWithParams.Parameters} + + let simpleRun = + [simpleConfig; nameConfig; simpleWithParams; fullConfig] + |> List.map (fun x -> (x, None)) + let complexRun = + [simpleConfig; nameConfig; simpleWithParams; fullConfig] + |> List.map (fun x -> (x, Some fullConfig)) + + simpleRun @ complexRun + |> List.map (fun x -> {MSBuildDefaults with DistributedLoggers = Some [x; x]}) + |> List.map MSBuildHelper.serializeMSBuildParams + |> List.iter (logfn "%s") +) + +RunTargetOrDefault "blah" + From 953432941968734337e70b18d240a8b0c19ae52c Mon Sep 17 00:00:00 2001 From: Chester Husk III Date: Thu, 4 Sep 2014 18:44:33 -0500 Subject: [PATCH 3/3] semicolon delimiters for msbuild distributed logger parameters --- src/app/FakeLib/MSBuildHelper.fs | 4 ++-- src/test/testscripts/test1.fsx | 30 +++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/app/FakeLib/MSBuildHelper.fs b/src/app/FakeLib/MSBuildHelper.fs index 2ab066d70f4..6ea9f4b5641 100644 --- a/src/app/FakeLib/MSBuildHelper.fs +++ b/src/app/FakeLib/MSBuildHelper.fs @@ -248,8 +248,8 @@ let serializeMSBuildParams (p : MSBuildParams) = (match dlogger.Parameters with | None -> "" | Some vars -> vars - |> List.fold (fun acc (k,v) -> sprintf "%s%s=%s," acc k v) "" - |> sprintf ";\"%s;\"" + |> List.fold (fun acc (k,v) -> sprintf "%s%s=%s;" acc k v) "" + |> sprintf ";\"%s\"" ) let createLoggerString cl fl = diff --git a/src/test/testscripts/test1.fsx b/src/test/testscripts/test1.fsx index c4f1009e33e..d1ed7d59b2d 100644 --- a/src/test/testscripts/test1.fsx +++ b/src/test/testscripts/test1.fsx @@ -10,11 +10,35 @@ Target "blah" (fun _ -> } let nameConfig = {simpleConfig with ClassName = Some "simpleClass"} - let simpleWithParams = {simpleConfig with Parameters = Some [("Verbosity", "High")]} + let simpleWithParams = {simpleConfig with Parameters = Some [("Verbosity", "High"); ("dupe2", "wat");]} let fullConfig = {simpleConfig with ClassName = nameConfig.ClassName Parameters = simpleWithParams.Parameters} + let wcl = Some [ + { + ClassName = Some "WorkflowCentralLogger" + AssemblyPath = "C:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll" + Parameters = + Some [ + "Verbosity", "Normal" + "BuildUri", "vstfs:///Build/Build/364" + "IgnoreDuplicateProjects", "False" + "InformationNodeId", sprintf "%d" 8 + "TargetsNotLogged", "GetNativeManifest,GetCopyToOutputDirectoryItems,GetTargetPath" + "TFSUrl", "https://ctaggart.visualstudio.com/DefaultCollection" + ] + }, + Some { + ClassName = Some "WorkflowForwardingLogger" + AssemblyPath = "C:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll" + Parameters = + Some [ + "Verbosity", "Normal" + ] + } + ] + let simpleRun = [simpleConfig; nameConfig; simpleWithParams; fullConfig] |> List.map (fun x -> (x, None)) @@ -22,8 +46,8 @@ Target "blah" (fun _ -> [simpleConfig; nameConfig; simpleWithParams; fullConfig] |> List.map (fun x -> (x, Some fullConfig)) - simpleRun @ complexRun - |> List.map (fun x -> {MSBuildDefaults with DistributedLoggers = Some [x; x]}) + [wcl] + |> List.map (fun x -> {MSBuildDefaults with DistributedLoggers = x}) |> List.map MSBuildHelper.serializeMSBuildParams |> List.iter (logfn "%s") )