fsprojects / FAKE

FAKE - F# Make

Home Page:https://fake.build

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update MSBuild.StructuredLogger to latest

KirillOsenkov opened this issue · comments

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

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

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!

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?

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.

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

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)

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.

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?

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

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

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

@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

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.