diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7899c81bf15..18e726cfaba 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -3,6 +3,7 @@ ## 6.0.1 - 2024-07-11 * BUGFIX: MSBuild.build adds a bad string at the end of properties, thanks @0x53A - https://github.com/fsprojects/FAKE/issues/2738 * ENHANCEMENT: Added shorthash to git functions, thanks @voronoipotato - https://github.com/fsprojects/FAKE/pull/2752 +* ENHANCEMENT: Support for `/tl:[auto:on:off]` msbuild flag, thanks @smoothdeveloper - https://github.com/fsprojects/FAKE/pull/2768 * ENHANCEMENT: Fixes for usage in .NET 8.0 enviroment projects. ## 6.0.0 - 2023-02-20 diff --git a/src/app/Fake.DotNet.MSBuild/MSBuild.fs b/src/app/Fake.DotNet.MSBuild/MSBuild.fs index 61c2322474f..66b24cd2888 100644 --- a/src/app/Fake.DotNet.MSBuild/MSBuild.fs +++ b/src/app/Fake.DotNet.MSBuild/MSBuild.fs @@ -33,6 +33,26 @@ type MSBuildVerbosity = | Detailed | Diagnostic +/// +/// Specifies whether the terminal logger should be used for the build output. The default is auto, which first verifies the environment before enabling terminal logging. The environment check verifies that the terminal is capable of using modern output features and isn't using a redirected standard output before enabling the new logger. on skips the environment check and enables terminal logging. off skips the environment check and uses the default console logger. +/// The terminal logger shows you the restore phase followed by the build phase. During each phase, the currently building projects appear at the bottom of the terminal. Each project that's building outputs both the MSBuild target currently being built and the amount of time spent on that target. You can search this information to learn more about the build. When a project is finished building, a single "build completed" section is written that captures: +/// +/// +/// +/// +/// This option is available starting in .NET 8. +[] +type MSBuildTerminalLoggerOption = + | On + | Off + | Auto + /// /// MSBuild log option /// See @@ -414,6 +434,9 @@ type MSBuildParams = /// Disable the default console logger, and don't log events to the console. NoConsoleLogger: bool + /// --tl[auto|on|off] + TerminalLogger: MSBuildTerminalLoggerOption + /// The list of warnings to treat as errors WarnAsError: string list option @@ -455,6 +478,7 @@ type MSBuildParams = ToolsVersion = None Verbosity = None NoConsoleLogger = false + TerminalLogger = MSBuildTerminalLoggerOption.Auto WarnAsError = None NoWarn = None RestorePackagesFlag = false @@ -529,6 +553,9 @@ module MSBuild = /// Disable the default console logger, and don't log events to the console. NoConsoleLogger: bool + /// --tl:[auto|on|off] + TerminalLogger: MSBuildTerminalLoggerOption + /// The list of warnings to treat as errors WarnAsError: string list option @@ -565,6 +592,7 @@ module MSBuild = ToolsVersion = None Verbosity = None NoConsoleLogger = false + TerminalLogger = MSBuildTerminalLoggerOption.Auto WarnAsError = None NoWarn = None DisableInternalBinLog = false @@ -588,6 +616,7 @@ module MSBuild = ToolsVersion = x.ToolsVersion Verbosity = x.Verbosity NoConsoleLogger = x.NoConsoleLogger + TerminalLogger = x.TerminalLogger WarnAsError = x.WarnAsError NoWarn = x.NoWarn DisableInternalBinLog = x.DisableInternalBinLog @@ -614,6 +643,7 @@ module MSBuild = ToolsVersion = x.ToolsVersion Verbosity = x.Verbosity NoConsoleLogger = x.NoConsoleLogger + TerminalLogger = x.TerminalLogger WarnAsError = x.WarnAsError NoWarn = x.NoWarn Loggers = x.Loggers @@ -859,6 +889,11 @@ module MSBuild = yield maxCpu yield noLogo yield nodeReuse + yield + (match p.TerminalLogger with + | MSBuildTerminalLoggerOption.Off -> Some("tl", "off") + | MSBuildTerminalLoggerOption.On -> Some("tl", "on") + | MSBuildTerminalLoggerOption.Auto -> None) yield tools yield verbosity yield noConsoleLogger diff --git a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs index 45db01aa551..8e46fe54909 100644 --- a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs +++ b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs @@ -6,6 +6,25 @@ open Expecto [] let tests = + let flagsTestCase name changeBuildArgs expected = + testCase name + <| fun _ -> + let _, cmdLine = MSBuild.buildArgs changeBuildArgs + + let expected = + if BuildServer.ansiColorSupport then + $"%s{expected} /clp:ForceConsoleColor".Trim() + else + expected.Trim() + + let expected = + if Environment.isUnix then + $"{expected} /p:RestorePackages=False".Trim() + else + $"/m /nodeReuse:False {expected} /p:RestorePackages=False".Trim() + + Expect.equal cmdLine expected $"Expected a given cmdLine '{expected}', but got '{cmdLine}'." + testList "Fake.DotNet.MSBuild.Tests" [ testCase "Test that we can create simple msbuild cmdline" @@ -37,4 +56,18 @@ let tests = else "/restore /m /nodeReuse:False /p:RestorePackages=False" - Expect.equal cmdLine expected "Expected a given cmdline." ] + Expect.equal cmdLine expected "Expected a given cmdline." + + flagsTestCase "/tl:auto doesn't ouput anything (1)" id "" + flagsTestCase + "/tl:auto doesn't ouput anything (2)" + (fun args -> { args with TerminalLogger = MSBuildTerminalLoggerOption.Auto }) + "" + flagsTestCase + "/tl:on does ouput" + (fun args -> { args with TerminalLogger = MSBuildTerminalLoggerOption.On }) + "/tl:on" + flagsTestCase + "/tl:off does ouput" + (fun args -> { args with TerminalLogger = MSBuildTerminalLoggerOption.Off }) + "/tl:off" ]