Skip to content

Update MSBuild.StructuredLogger to latest #2744

Open

Description

@KirillOsenkov

I'm not sure how this works, but this seems to be using an old version of the
MSBuild.StructuredLogger package:

FAKE/paket.lock

Line 805 in 13e3033

MSBuild.StructuredLogger (2.1.545)

The latest version is:
https://www.nuget.org/packages/MSBuild.StructuredLogger/2.1.814

Without the latest version, builds fail with:

Unhandled exception. Fake.Core.BuildFailedException: Target 'PrepareMSBuildTests' failed.
 ---> System.AggregateException: One or more errors occurred. (Unsupported log file format. Latest supported version is 14, the log file has version 15.)
 ---> System.NotSupportedException: Unsupported log file format. Latest supported version is 14, the log file has version 15.
   at Microsoft.Build.Logging.StructuredLogger.BinLogReader.ReadRecordsFromDecompressedStream(Stream decompressedStream)+MoveNext() in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BinLogReader.cs:line 218
   at Microsoft.FSharp.Collections.Internal.IEnumerator.choose@171.System.Collections.IEnumerator.MoveNext() in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 178
   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   at Fake.DotNet.MSBuildBinLog.getErrorsAndWarnings(String binLogFilePath)
   at Fake.DotNet.MSBuild.handleAfterRun(String command, FSharpOption`1 binLogPath, Int32 exitCode, String project)
   at Fake.DotNet.DotNet.pack(FSharpFunc`2 setParams, String project)
   at Build.prepareMSBuildTests[a](a _arg1) in C:\Farkle\eng\build.fs:line 217
   at Build.initTargets@417-6.Invoke(TargetParameter arg00@)
   at Fake.Core.TargetModule.runSimpleInternal(TargetContext context, Target target)
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at Fake.Core.TargetModule.raiseIfError(OptionalTargetContext context)
   at Fake.Core.TargetModule.runOrDefaultWithArguments(String defaultTarget)
   at Build.main(String[] argv) in C:\Farkle\eng\build.fs:line 506

Activity

  1. github-actions commented on Apr 21, 2023

    @github-actions
    Contributor

    Welcome to the FAKE community! Thank you so much for creating your first issue and therefore improving the project!

  2. baronfel commented on Apr 21, 2023

    @baronfel
    Contributor

    FAKE automatically creates binlogs for most builds that are orchestrated through FAKE, and then reads the warnings/errors directly from the binlog to prevent any parsing issues. As a result, it needs to keep bumped! It should be no impact to the rest of FAKE to bump this, so I'd encourage @yazeedobaid to do so at the earliest opportunity!

  3. KirillOsenkov commented on Apr 21, 2023

    @KirillOsenkov
    Author

    How do you guys specify a version? Where does 2.1.545 come from in paket.lock?

    I'm hitting this problem while building dotnet/msbuild#8478 (comment) with FAKE. I searched the Farkle repo, and I only found these occurrences:

    image

    Doesn't seem to be the "source" of where this value is flowing from?

  4. gtbuchanan commented on May 16, 2023

    @gtbuchanan

    As a workaround, you can just reference the most recent version of MSBuild.StructuredLogger from your project to force it to bump the transitive dependency.

  5. thinkbeforecoding commented on Feb 15, 2024

    @thinkbeforecoding
    Contributor

    The latest version (2.2.206) version of MSBuild.StructuredLogger fails with a ArgumentNullException. It seems it's due to localized string not being initialized.

    This can be fixed by adding the following line at the start of build script:

    Microsoft.Build.Logging.StructuredLogger.Strings.Initialize()
    

    This could be done directly in Fake to avoid the problem

  6. KirillOsenkov commented on Feb 15, 2024

    @KirillOsenkov
    Author

    do you have the full callstack? mind filing an issue on https://github.com/KirillOsenkov/MSBuildStructuredLog/issues/new

    I want to fix this (and I thought I did)

  7. baronfel commented on Feb 15, 2024

    @baronfel
    Contributor

    In addition, for the May release we should finally ship a version of binlogs that are forward-compatible, so you could update to the version to be released then and then not have to update ever again - until/unless you need support for a new kind of message that is introduced. But since FAKE's binlog integration is very simple (just warnings/errors) that should be enough for quite a long time.

  8. Numpsy commented on Feb 18, 2024

    @Numpsy
    Contributor

    I tried to update the structured log lib to a newer version in the FAKE build a while ago and it caused the integration tests to fail, possibly because it depends on Microsoft.Build.Framework 17.5.0 which doesn't have a .NET 6 TFM anymore, so I'm not sure what the procedure to update here should be as long as everything is here is built around .NET 6.0?

  9. KirillOsenkov commented on Feb 18, 2024

    @KirillOsenkov
    Author

    Is this the issue you're running into?
    KirillOsenkov/MSBuildStructuredLog#692

  10. KirillOsenkov commented on Feb 18, 2024

    @KirillOsenkov
    Author

    Basically if things fail we need to investigate and fix them.

  11. Numpsy commented on Feb 18, 2024

    @Numpsy
    Contributor

    Is this the issue you're running into? KirillOsenkov/MSBuildStructuredLog#692

    it was something like that (the CI build attempt from here seems to have expired and deleted the logs though).

    Also sounds similar to #2722

  12. anpin commented on Apr 17, 2024

    @anpin

    @KirillOsenkov FYI

    I think I'm running in the same issue here

    I have added <PackageVersion Include="MSBuild.StructuredLogger" Version="2.2.206" /> to fix aforementioned error, and it runs fine locally on my dev machine. However in the CI it fails with

    Unhandled exception. Fake.Core.BuildFailedException: Target 'Build' failed.
     ---> System.AggregateException: One or more errors occurred. (Value cannot be null. (Parameter 'format'))
     ---> System.ArgumentNullException: Value cannot be null. (Parameter 'format')
       at System.ArgumentNullException.Throw(String paramName)
       at System.String.FormatHelper(IFormatProvider provider, String format, ReadOnlySpan`1 args)
       at System.String.Format(String format, Object[] args)
       at Microsoft.Build.Logging.StructuredLogger.BuildEventArgsReader.FormatResourceStringIgnoreCodeAndKeyword(String resource, String[] arguments) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BuildEventArgsReader.Viewer.cs:line 198
       at Microsoft.Build.Logging.StructuredLogger.BuildEventArgsReader.GetPropertyReassignmentMessage(String propertyName, String newValue, String previousValue, String location) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BuildEventArgsReader.Viewer.cs:line 72
       at Microsoft.Build.Logging.StructuredLogger.BuildEventArgsReader.ReadPropertyReassignmentEventArgs() in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BuildEventArgsReader.cs:line 1276
       at Microsoft.Build.Logging.StructuredLogger.BuildEventArgsReader.ReadBuildEventArgs(BinaryLogRecordKind recordKind) in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BuildEventArgsReader.cs:line 329
       at Microsoft.Build.Logging.StructuredLogger.BuildEventArgsReader.Read() in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BuildEventArgsReader.cs:line 246
       at Microsoft.Build.Logging.StructuredLogger.BinLogReader.ReadRecordsFromDecompressedStream(BuildEventArgsReader reader, Boolean includeAuxiliaryRecords)+MoveNext() in C:\MSBuildStructuredLog\src\StructuredLogger\BinaryLogger\BinLogReader.cs:line 440
       at Microsoft.FSharp.Collections.Internal.IEnumerator.choose@171.System.Collections.IEnumerator.MoveNext() in D:\a\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 178
       at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
       at Fake.DotNet.MSBuildBinLog.getErrorsAndWarnings(String binLogFilePath) in D:\a\FAKE\FAKE\src\app\Fake.DotNet.MSBuild\BinLog.fs:line 48
       at Fake.DotNet.MSBuild.handleAfterRun(String command, FSharpOption`1 binLogPath, Int32 exitCode, String project) in D:\a\FAKE\FAKE\src\app\Fake.DotNet.MSBuild\MSBuild.fs:line 957
       at Fake.DotNet.DotNet.build(FSharpFunc`2 setParams, String project) in D:\a\FAKE\FAKE\src\app\Fake.DotNet.Cli\DotNet.fs:line 1654
       at Build.build[a](a _arg1) in /home/vsts/work/1/s/src/Build/Build.fs:line 60
       at Build.initTargets@299-5.Invoke(TargetParameter arg00@)
       at Fake.Core.TargetModule.runSimpleInternal(TargetContext context, Target target) in D:\a\FAKE\FAKE\src\app\Fake.Core.Target\Target.fs:line 371
       --- End of inner exception stack trace ---
       --- End of inner exception stack trace ---
       at Fake.Core.TargetModule.raiseIfError(OptionalTargetContext context) in D:\a\FAKE\FAKE\src\app\Fake.Core.Target\Target.fs:line 1319
       at Fake.Core.TargetModule.runOrDefaultWithArguments(String defaultTarget) in D:\a\FAKE\FAKE\src\app\Fake.Core.Target\Target.fs:line 1542
       at Build.main(String[] argv) in /home/vsts/work/1/s/src/Build/Build.fs:line 341
    
    

    Call site:

    let build _ =
        solutionFile
        |> DotNet.build <--- line 60
            (fun p ->
                { p with 
                    Configuration = configuration
                    }) 
    

    EDIT: the workaround by @thinkbeforecoding does work

  13. KirillOsenkov commented on Apr 18, 2024

    @KirillOsenkov
    Author

    my apologies, I haven't gotten the time to get to this. For now please use Strings.Initialize() and I'll fix it properly at some point later.

  14. xperiandri commented on Sep 1, 2024

    @xperiandri
    Collaborator

    @Thorium have we already updated that?

  15. KirillOsenkov commented on Sep 1, 2024

    @KirillOsenkov
    Author

    I think the latest version should fix this without calling Strings.Initialize() manually

  16. Numpsy commented on Sep 2, 2024

    @Numpsy
    Contributor

    @Thorium have we already updated that?

    Last I looked, doing the update was blocked by the FAKE build being pinned to Microsoft.Build 17.3.2 and the latest StructuredLogger needing 17.5.0 (and the update to that may or may not be blocked by MSBuild 17.5 having removed the .NET 6.0 TFM in favour of .NET 7.0)

  17. Thorium commented on Sep 2, 2024

    @Thorium
    Member

    I don't think so.
    Where I'm using FAKE, I went for MSBuild.StructuredLogger 2.2.291 and then I'm using:

        Fake.DotNet.DotNet.build (fun p -> 
          {
            p with 
              Configuration = DotNet.BuildConfiguration.Release
              MSBuildParams = { MSBuild.CliArguments.Create() with DisableInternalBinLog = true }
        
        }) "MySolution.sln"
    

    ...and it compiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions