BenchmarkDotNet
BenchmarkDotNet copied to clipboard
[Feature Request] Reduce output binary size of project build results
When building BenchmarkDotNet project.
bin directory takes about 79MB, and runtimes directory takes about 47MB of them.
These files are also outputted for build results of CsProjToolChain.
Is it able to remove these files?
These runtimes files are almost copied from Gee.External.Capstone package.
And these files seems required when using DisassemblyDiagnoser and requires only benchmark target runtime.
I thought it's better to copy runtime that are required for current build environment by default. Playwright.NET using this approach. https://playwright.dev/dotnet/docs/library#bundle-drivers-for-different-platforms
Example custom MSBuild target I've confirmed. It can remove runtimes files by using following custom target. (Note: It's tested Windows Environment only)
<PropertyGroup>
<!-- When TargetFramework containstarget platform -->
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform )' == ''">%(RuntimePack.RuntimeIdentifier)</BenchmarkDotNetTargetPlatform >
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform )' == ''">$(RuntimeIdentifier)</BenchmarkDotNetTargetPlatform >
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform )' == ''">$(RuntimeIdentifiers)</BenchmarkDotNetTargetPlatform >
<!-- Otherwise, resolve current build platform -->
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X86'">linux-X86</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">linux-x64</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">linux-arm64</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('Windows')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X86'">win-x86</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('Windows')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">win-x64</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('Windows')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">win-arm64</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('OSX')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">osx-x64</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('OSX')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">osx-arm64</BenchmarkDotNetTargetPlatform>
</PropertyGroup>
<Target Name="FilterCopyLocalFiles" AfterTargets="ResolveLockFileCopyLocalFiles">
<ItemGroup Condition="'$(BenchmarkDotNetTargetPlatform)' != '' AND $(BenchmarkDotNetTargetPlatform) != 'all'">
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"
Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' == 'Gee.External.Capstone' AND '%(ReferenceCopyLocalPaths.RuntimeIdentifier)' != $(BenchmarkDotNetTargetPlatform)" />
</ItemGroup>
</Target>
Additionally Microsoft.CodeAnalysis satellite assemblies takes about 6MB.
These files should be removed also if possible. (via SatelliteResourceLanguages property or custom MSBuild target)