fsprojects / FAKE

FAKE - F# Make
https://fake.build
Other
1.28k stars 582 forks source link

Error detecting msbuild version on Linux #2709

Closed otto-gebb closed 1 year ago

otto-gebb commented 1 year ago

Description

On Linux, FAKE outputs an error when it tries to detect the version of msbuild:

/home/gebb/_c/PrismaCloud/svc_OtaUpdater> "/usr/bin/dotnet" msbuild /version /nologo (In: false, Out: true, Err: true) /version(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. Could not detect msbuild version from '/usr/bin/dotnet msbuild': System.Exception: msbuild failed with exitcode '1' at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1439.Invoke(String message) in D:\workspace_work\1\s\src\fsharp\FSharp.Core\printf.fs:line 1439 at Fake.DotNet.DotNet.callMsBuildExe@1055.Invoke(String args) in D:\a\1\s\src\app\Fake.DotNet.Cli\DotNet.fs:line 1068 at Fake.DotNet.MSBuild.getFromCall@690(String exePath, FSharpFunc`2 callMsbuildExe, Unit unitVar0) in D:\a\1\s\src\app\Fake.DotNet.MSBuild\MSBuild.fs:line 692 msbuild version '13.0.0.0' doesn't support binary logger, please set the msbuild argument 'DisableInternalBinLog' to 'true' to disable this warning.

I tried issuing the same command as FAKE does, and got this result: image

As we see, the command would have succeeded if FAKE were using double dashes instead of slashes.

The relevant code, I believe, is here.

  let internal getVersion =
      let cache = System.Collections.Concurrent.ConcurrentDictionary<string, Version>()
      fun (exePath:string) (callMsbuildExe: string -> string) ->
          let getFromCall() =
            try
                let result = callMsbuildExe "/version /nologo"
  // ...

Repro steps

  1. Create a build script on Linux, containing a call to DotNet.build.
  2. Run the script.

Expected behavior

No error.

Actual behavior

An error is shown.

Related information

yazeedobaid commented 1 year ago

Released in 6.0.0-beta001