From 8125ed080adf36db4847705c0aa5c73737927acd Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Mon, 11 Dec 2023 02:05:10 +0100 Subject: [PATCH 1/9] add support for /tl:[auto|on|off] msbuild flag --- RELEASE_NOTES.md | 1 + src/app/Fake.DotNet.MSBuild/MSBuild.fs | 33 +++++++++++++++++++ .../Fake.DotNet.MSBuild.fs | 29 +++++++++++++++- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7899c81bf15..a457d0b0de5 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,6 +4,7 @@ * 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: Fixes for usage in .NET 8.0 enviroment projects. +* ENHANCEMENT: Support for /tl:[auto:on:off] msbuild flag, thanks @smoothdeveloper - ## 6.0.0 - 2023-02-20 * ENHANCEMENT: Site UI fixes and documentation link fixes. diff --git a/src/app/Fake.DotNet.MSBuild/MSBuild.fs b/src/app/Fake.DotNet.MSBuild/MSBuild.fs index 61c2322474f..6e862083f4c 100644 --- a/src/app/Fake.DotNet.MSBuild/MSBuild.fs +++ b/src/app/Fake.DotNet.MSBuild/MSBuild.fs @@ -33,6 +33,24 @@ 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: +/// +/// * The name of the built project. +/// * The target framework (if multi-targeted). +/// * The status of that build. +/// * The primary output of that build (which is hyperlinked). +/// * Any diagnostics generated for that project. +/// This option is available starting in .NET 8. +/// +[] +type MSBuildTerminalLoggerOption = + | On + | Off + | Auto + /// /// MSBuild log option /// See @@ -414,6 +432,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 +476,7 @@ type MSBuildParams = ToolsVersion = None Verbosity = None NoConsoleLogger = false + TerminalLogger = MSBuildTerminalLoggerOption.Auto WarnAsError = None NoWarn = None RestorePackagesFlag = false @@ -529,6 +551,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 +590,7 @@ module MSBuild = ToolsVersion = None Verbosity = None NoConsoleLogger = false + TerminalLogger = MSBuildTerminalLoggerOption.Auto WarnAsError = None NoWarn = None DisableInternalBinLog = false @@ -588,6 +614,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 +641,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 +887,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..7d78bceb3b8 100644 --- a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs +++ b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs @@ -6,6 +6,19 @@ open Expecto [] let tests = + let flagsTestCase name changeBuildArgs expected = + testCase name + <| fun _ -> + let _, cmdLine = MSBuild.buildArgs changeBuildArgs + + let expected = + if Environment.isUnix then + $"{expected} /p:RestorePackages=False".Trim() + else + $"{expected} /m /nodeReuse:False /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 +50,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" ] From f4a9666ff93a8d661628e7a07433b33cdfa83406 Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Mon, 11 Dec 2023 02:14:53 +0100 Subject: [PATCH 2/9] adjust link to PR --- RELEASE_NOTES.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index a457d0b0de5..9002e6586bd 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -3,8 +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: Fixes for usage in .NET 8.0 enviroment projects. -* ENHANCEMENT: Support for /tl:[auto:on:off] msbuild flag, thanks @smoothdeveloper - +* 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 * ENHANCEMENT: Site UI fixes and documentation link fixes. From a0ac65c9609af18749a985b3ca514ef1805d7d17 Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Mon, 11 Dec 2023 02:34:30 +0100 Subject: [PATCH 3/9] try to fix CI --- src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs index 7d78bceb3b8..e22ab1f3cba 100644 --- a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs +++ b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs @@ -11,6 +11,12 @@ let tests = <| 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() From 51ec5328c6dcfa59674e1228cded5a53c1e83f70 Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Mon, 11 Dec 2023 02:53:39 +0100 Subject: [PATCH 4/9] whitespace vs fantomas --- src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs index e22ab1f3cba..b15565f679a 100644 --- a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs +++ b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs @@ -16,7 +16,7 @@ let tests = $"%s{expected} /clp:ForceConsoleColor".Trim() else expected.Trim() - + let expected = if Environment.isUnix then $"{expected} /p:RestorePackages=False".Trim() From b0e2cf67f1cb3395564d4a03d7d47b66b60e6bcb Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Mon, 11 Dec 2023 14:59:44 +0100 Subject: [PATCH 5/9] try fix windows CI --- src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs index b15565f679a..8e46fe54909 100644 --- a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs +++ b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs @@ -21,7 +21,7 @@ let tests = if Environment.isUnix then $"{expected} /p:RestorePackages=False".Trim() else - $"{expected} /m /nodeReuse:False /p:RestorePackages=False".Trim() + $"/m /nodeReuse:False {expected} /p:RestorePackages=False".Trim() Expect.equal cmdLine expected $"Expected a given cmdLine '{expected}', but got '{cmdLine}'." From cb44fb3a431b8eed2b0d978602b0df7ac62628b9 Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Mon, 11 Dec 2023 20:56:41 +0100 Subject: [PATCH 6/9] Update src/app/Fake.DotNet.MSBuild/MSBuild.fs Good point, thanks! Co-authored-by: Andrii Chebukin --- src/app/Fake.DotNet.MSBuild/MSBuild.fs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/Fake.DotNet.MSBuild/MSBuild.fs b/src/app/Fake.DotNet.MSBuild/MSBuild.fs index 6e862083f4c..33d5c3c2826 100644 --- a/src/app/Fake.DotNet.MSBuild/MSBuild.fs +++ b/src/app/Fake.DotNet.MSBuild/MSBuild.fs @@ -37,12 +37,13 @@ type MSBuildVerbosity = /// 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: -/// -/// * The name of the built project. -/// * The target framework (if multi-targeted). -/// * The status of that build. -/// * The primary output of that build (which is hyperlinked). -/// * Any diagnostics generated for that project. +///
    +///
  • The name of the built project.
  • +///
  • The target framework (if multi-targeted).
  • +///
  • The status of that build.
  • +///
  • The primary output of that build (which is hyperlinked).
  • +///
  • Any diagnostics generated for that project.
  • +///
/// This option is available starting in .NET 8. ///
[] From e66fd9a57a2873b9c0b6685be8cf9d52d48dfe6c Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Mon, 11 Dec 2023 20:56:51 +0100 Subject: [PATCH 7/9] Update src/app/Fake.DotNet.MSBuild/MSBuild.fs Co-authored-by: Andrii Chebukin --- src/app/Fake.DotNet.MSBuild/MSBuild.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/Fake.DotNet.MSBuild/MSBuild.fs b/src/app/Fake.DotNet.MSBuild/MSBuild.fs index 33d5c3c2826..9a81e48d6dc 100644 --- a/src/app/Fake.DotNet.MSBuild/MSBuild.fs +++ b/src/app/Fake.DotNet.MSBuild/MSBuild.fs @@ -44,8 +44,8 @@ type MSBuildVerbosity = ///
  • The primary output of that build (which is hyperlinked).
  • ///
  • Any diagnostics generated for that project.
  • /// -/// This option is available starting in .NET 8. /// +/// This option is available starting in .NET 8. [] type MSBuildTerminalLoggerOption = | On From 21c36deeef52d5bd78f15888f26fef7ee8166928 Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Mon, 11 Dec 2023 23:37:36 +0100 Subject: [PATCH 8/9] wrap help text in tags for better rendering in IDE --- src/app/Fake.DotNet.MSBuild/MSBuild.fs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/Fake.DotNet.MSBuild/MSBuild.fs b/src/app/Fake.DotNet.MSBuild/MSBuild.fs index 9a81e48d6dc..66b24cd2888 100644 --- a/src/app/Fake.DotNet.MSBuild/MSBuild.fs +++ b/src/app/Fake.DotNet.MSBuild/MSBuild.fs @@ -34,9 +34,9 @@ type MSBuildVerbosity = | 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: +/// 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: +/// ///
      ///
    • The name of the built project.
    • ///
    • The target framework (if multi-targeted).
    • @@ -44,6 +44,7 @@ type MSBuildVerbosity = ///
    • The primary output of that build (which is hyperlinked).
    • ///
    • Any diagnostics generated for that project.
    • ///
    +///
    ///
    /// This option is available starting in .NET 8. [] From bae82a67d0cdc1e60483c2803a6e643de5a59aba Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Thu, 25 Jul 2024 00:15:31 +0200 Subject: [PATCH 9/9] (minor) glitch in release notes merge --- RELEASE_NOTES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9002e6586bd..18e726cfaba 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -3,7 +3,8 @@ ## 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. +* 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 * ENHANCEMENT: Site UI fixes and documentation link fixes.