BenchmarkDotNet
BenchmarkDotNet copied to clipboard
Build native project dependency
I have some csproj that references a vcxproj and that builds just fine in Visual Studio. However, dotnet build (as used internally) does not support building native projects. I am wonder if there's a way to skip the building of these native dependencies (tried --no-dependencies to no avail) and provide the prebuild binaries myself?
Hi @pr8x
I am wonder if there's a way to skip the building of these native dependencies (tried --no-dependencies to no avail) and provide the prebuild binaries myself?
BenchmarkDotNet does not offer anything like this and I rather don't see us implementing it.
What target framework are you targetting? .NET or .NET Core? How do you build your app and run it without VS?
You can always use the InProcessToolchain which runs everything in proc without generating and building a new project
Hi, I am targeting .NET 5. Apart from VS I use nuke to build my app on the CI, but I doubt they allow to build a single project (would probably require some extra setup). I could probably try to invoke MSBuild directly somehow. Does Benchmark.NET have support for a MSBuild toolchain (that doesn't use dotnet build internally)?
You can always use the InProcessToolchain which runs everything in proc without generating and building a new project
I tried using InProcess on my benchmark suite, but that also tries (and fails) to build the project. For reference, the error I am getting:
The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Does Benchmark.NET have support for a MSBuild toolchain (that doesn't use dotnet build internally)?
It does not, but dotnet build "should just work" ;)
I tried using InProcess on my benchmark suite, but that also tries (and fails) to build the project.
Do I understand correctly that even if you remove BenchmarkDotNet from your project you still can not build it from the console using dotnet build despite the fact that it's a .NET Core app?
As mentioned above dotnet build cannot deal with native/C++ projects (see https://github.com/dotnet/sdk/issues/10239). So, yes, it fails to compile the .NET Core project since that is referencing a C++ project. This is supported in MSBuild, but apparently not by w/e toolchain is used by dotnet build. I think I might need to write some custom MSBuild driver to make this work then.
@pr8x Maybe this will help you https://wojciechnagorski.com/2019/09/using-native-dll-and-resource-files-in-benchmarkdotnet-projects
There is a sample repo https://github.com/WojciechNagorski/NativeMemorySample