BenchmarkDotNet icon indicating copy to clipboard operation
BenchmarkDotNet copied to clipboard

`--generateBinlog` working incorrectly: not building due to msbuild error.

Open DoctorVanGogh opened this issue 1 month ago • 0 comments

I'm trying to track down an issue where a benchmark (using EtwProfiler) will not run (turns out, some things are missing from the app.config in the second order builds). To narrow down the issue I tried specifying --generateBinlog on the command line. Sadly that brought about more issues 😞

MSBuild error with --generateBinlog

Specifying --generateBinlog on my .Net Framework 4.7.2 project will cause the entire second order builds not to run with a msbuild error:

...
start dotnet  restore /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true -bl:.NET Framework 4.7.2-restore.binlog in ***\bin\Release\net472\.NET Framework 4.7.2
MSBUILD : error MSB1008: Only one project can be specified.
    Full command line: 'C:\Program Files\dotnet\sdk\8.0.204\MSBuild.dll -maxcpucount -verbosity:m -nologo -target:Restore --property:UseSharedCompilation=false --property:BuildInParallel=false --property:Deterministic=true --property:Optimize=true /m:1 -bl:.NET Framework 4.7.2-restore.binlog -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\8.0.204\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\8.0.204\dotnet.dll'
  Switches appended by response files:
Switch: 4.7.2-restore.binlog
// Build Error: Standard output:

 Standard error:
 MSBUILD : error MSB1008: Only one project can be specified.
    Full command line: 'C:\Program Files\dotnet\sdk\8.0.204\MSBuild.dll -maxcpucount -verbosity:m -nologo -target:Restore --property:UseSharedCompilation=false --property:BuildInParallel=false --property:Deterministic=true --property:Optimize=true /m:1 -bl:.NET Framework 4.7.2-restore.binlog -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\8.0.204\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\8.0.204\dotnet.dll'
  Switches appended by response files:
Switch: 4.7.2-restore.binlog
For switch syntax, type "MSBuild -help"

// command took 0.16 sec and exited with 1
// ***** Done, took 00:00:01 (1.21 sec)   *****
// Found 1 benchmarks:
//   Foo.Bar: .NET Framework 4.7.2(Runtime=.NET Framework 4.7.2) [wiz=bang]
...
// Build Error: Standard output:

 Standard error:
 MSBUILD : error MSB1008: Only one project can be specified.
    Full command line: 'C:\Program Files\dotnet\sdk\8.0.204\MSBuild.dll -maxcpucount -verbosity:m -nologo -target:Restore --property:UseSharedCompilation=false --property:BuildInParallel=false --property:Deterministic=true --property:Optimize=true /m:1 -bl:.NET Framework 4.7.2-restore.binlog -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\8.0.204\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\8.0.204\dotnet.dll'
  Switches appended by response files:
Switch: 4.7.2-restore.binlog
For switch syntax, type "MSBuild -help"

// BenchmarkDotNet has failed to build the auto-generated boilerplate code.
// It can be found in [***]\bin\Release\net472\.NET Framework 4.7.2
// Please follow the troubleshooting guide: https://benchmarkdotnet.org/articles/guides/troubleshooting.html

It seems the response file for the added switches does not properly quote its arguments. Specifically it should be -bl:'. NET Framework 4.7.2-restore.binlog', not -bl:. NET Framework 4.7.2-restore.binlog.

Secondary issue: --keepFiles does not in fact keep all files 😉

It seems there are some response files in use that contain options. Alas, those response files seem not to be kept even when using --keepFiles.

...
Switches appended by response files:
Switch: 4.7.2-restore.binlog
...

The build artefact directory contains a .bat file, a .notcsfile and a .csproj. No .rsp ☹️

DoctorVanGogh avatar May 17 '24 05:05 DoctorVanGogh