You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to set up benchmarks for a library projects where I use the simplified artifacts output layout and Directory.Build.props at the root where I define multiple target frameworks for the library (including .NET Standard 2.0).
The issue is that when I build the benchmark project for .NET 8, its auto generated project includes the same Directory.Build.props at the root (as that's the closest one to the .artifacts folder, it starts targeting .NET Standard 2.0 and I get an error:
// Validating benchmarks:
// ***** BenchmarkRunner: Start *****
// ***** Found 2 benchmark(s) in total *****
// ***** Building 1 exe(s) in Parallel: Start *****
// start dotnet restore /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true /p:IntermediateOutputPath="C:\Users\titas\Code\BenchmarkDotNet-BuildDirectoryPropsIssue\.artifacts\bin\SampleBenchmark\debug_win-x64\61614065-6a51-405e-b88a-4650444e5ee0\obj\Release\net8.0/" /p:OutDir="C:\Users\titas\Code\BenchmarkDotNet-BuildDirectoryPropsIssue\.artifacts\bin\SampleBenchmark\debug_win-x64\61614065-6a51-405e-b88a-4650444e5ee0\bin\Release\net8.0/" /p:OutputPath="C:\Users\titas\Code\BenchmarkDotNet-BuildDirectoryPropsIssue\.artifacts\bin\SampleBenchmark\debug_win-x64\61614065-6a51-405e-b88a-4650444e5ee0\bin\Release\net8.0/" in C:\Users\titas\Code\BenchmarkDotNet-BuildDirectoryPropsIssue\.artifacts\bin\SampleBenchmark\debug_win-x64\61614065-6a51-405e-b88a-4650444e5ee0
// command took 1.58 sec and exited with 1
// ***** Done, took 00:00:01 (1.67 sec) *****
// Found 2 benchmarks:
// BenchmarkClass.Scenario1: DefaultJob
// BenchmarkClass.Scenario2: DefaultJob
Setup power plan (GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c FriendlyName: High performance)
// Build Error: Standard output:
Standard error:
Determining projects to restore...
C:\Users\titas\Code\BenchmarkDotNet-BuildDirectoryPropsIssue\.artifacts\bin\SampleBenchmark\debug_win-x64\61614065-6a51-405e-b88a-4650444e5ee0\BenchmarkDotNet.Autogenerated.csproj : error NU1201: Project SampleBenchmark is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project SampleBenchmark supports: net8.0 (.NETCoreApp,Version=v8.0) [TargetFramework=net8.0]
Failed to restore C:\Users\titas\Code\BenchmarkDotNet-BuildDirectoryPropsIssue\.artifacts\bin\SampleBenchmark\debug_win-x64\61614065-6a51-405e-b88a-4650444e5ee0\BenchmarkDotNet.Autogenerated.csproj (in 369 ms).
1 of 2 projects are up-to-date for restore.
// BenchmarkDotNet has failed to build the auto-generated boilerplate code.
// It can be found in C:\Users\titas\Code\BenchmarkDotNet-BuildDirectoryPropsIssue\.artifacts\bin\SampleBenchmark\debug_win-x64\61614065-6a51-405e-b88a-4650444e5ee0
// Please follow the troubleshooting guide: https://benchmarkdotnet.org/articles/guides/troubleshooting.html
I've set up a minimal example to illustrate it here
Now one possible solution I've found that works for me is to define the framework targets in Directory.Build.props in a conditional PropertyGroup:
which presumably should avoid importing the Directory.Build.props but it seems that it gets imported before the .csproj which makes them not do anything (if they are indeed expected to).
Would it be possible to somehow pass in ImportDirectoryBuildProps=false and ImportDirectoryBuildTargets=false as part of the build command to make sure they are defined early enough? Not sure if that would work but just an idea
The text was updated successfully, but these errors were encountered:
Hi,
I'm trying to set up benchmarks for a library projects where I use the simplified artifacts output layout and
Directory.Build.props
at the root where I define multiple target frameworks for the library (including .NET Standard 2.0).The issue is that when I build the benchmark project for .NET 8, its auto generated project includes the same
Directory.Build.props
at the root (as that's the closest one to the.artifacts
folder, it starts targeting .NET Standard 2.0 and I get an error:I've set up a minimal example to illustrate it here
Now one possible solution I've found that works for me is to define the framework targets in
Directory.Build.props
in a conditionalPropertyGroup
:But I feel like the benchmarking library should handle this somehow.
What I've seen is that the auto generated
BenchmarkDotNet.Autogenerated.csproj
contains:which presumably should avoid importing the
Directory.Build.props
but it seems that it gets imported before the.csproj
which makes them not do anything (if they are indeed expected to).Would it be possible to somehow pass in
ImportDirectoryBuildProps=false
andImportDirectoryBuildTargets=false
as part of the build command to make sure they are defined early enough? Not sure if that would work but just an ideaThe text was updated successfully, but these errors were encountered: