Skip to content

'BenchmarkDotNet.Autogenerated\project.assets.json' not found.  #1795

Closed
@ddhokler

Description

@ddhokler

Maybe change this title to "BenchmarkDotNet" writes auto-generated object files to wrong directory.

My SDK builds use a Directory.Build.props file in the root directory of the repository, which defines the following:

    <BuildPath Condition="'$(BuildPath)'==''">$(MSBuildThisFileDirectory)build\</BuildPath>
    <BaseIntermediateOutputPath>$(BuildPath)obj\$(Configuration)\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
    <IntermediateOutputPath>$(BuildPath)obj\$(Configuration)\$(MSBuildProjectName)\</IntermediateOutputPath>
    <OutputPath>$(BuildPath)bin\$(Configuration)\$(MSBuildProjectName)\</OutputPath>

in other words the output directory should look like this:
build\bin\Release
build\obj\Release\

Yet BenchmarkDotNet produced autogenerated object files under the following directories.
build\obj\BenchmarkDotNet.Autogenerated\ // 1.) this contained complete object files including project.assets.json, but was not
build\obj\Release\BenchmarkDotNet.Autogenerated\ // 2.) was also created, but did not contain 'project.assets.json'

Running Benchmark produced the following output:

C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file 'C:\<redacted>\build\obj\Release\BenchmarkDotNet.Autogenerated\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\<redacted>\build\bin\Release\Parsing.Benchmarks\netcoreapp2.0\8e8f1576-998b-44af-ac84-a1b84418ccb8\BenchmarkDotNet.Autogenerated.csproj]
Build FAILED.

I found that the BenchmarkDotNet.Autogenerated.csproj (found in build\bin\Release\Parsing.Benchmarks\netcoreapp2.0\8e8f1576-998b-44af-ac84-a1b84418ccb8) defined the following:
<ImportDirectoryBuildProps>**false**</ImportDirectoryBuildProps>
which is not cool.

Manually changing ImportDirectoryBuildProps=true allowed the 'project.assests.json' to be created under build\obj\Release\BenchamrkDotNet.Autogenerated and the benchmarks executed correctly. However upon Rebuild Solution, it continued to run correctly (the BenchmarkDotNet.Autogenerated.csproj file was not replaced).

I also tried specifying
job.WithArguments(new Argument[] { new MsBuildArgument("/p:ImportDirectoryBuildProps=true") });
but the string was not recognized.

It seems like BenchmarkDotNet is inconsistent about where to put and find object files. It recognizes the MSBuild OutputPath and IntermediateOutputPath, but not BaseIntermediateOutputPath. Even though ImportDirectoryBuildProps is false, it still uses it to output to the build directory.

This is all very annoying. BenchmarkDotNet worked great under NetFX, but this is a struggle.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions