Skip to content

Commit 7067dfd

Browse files
authored
chore: add setting to remove unused files from output bin directory (#3192)
1 parent 40736e9 commit 7067dfd

5 files changed

Lines changed: 29 additions & 5 deletions

File tree

BenchmarkDotNet.slnx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
</Folder>
66
<Folder Name="/samples/">
77
<File Path="samples/Directory.Build.props" />
8+
<File Path="samples/Directory.Build.targets" />
89
<Project Path="samples/BenchmarkDotNet.Samples.FSharp/BenchmarkDotNet.Samples.FSharp.fsproj" />
910
<Project Path="samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj" DefaultStartup="true" />
1011
</Folder>
@@ -28,6 +29,7 @@
2829
</Folder>
2930
<Folder Name="/tests/">
3031
<File Path="tests/Directory.Build.props" />
32+
<File Path="tests/Directory.Build.targets" />
3133
<Project Path="tests/BenchmarkDotNet.Analyzers.Tests/BenchmarkDotNet.Analyzers.Tests.csproj" />
3234
<Project Path="tests/BenchmarkDotNet.Exporters.Plotting.Tests/BenchmarkDotNet.Exporters.Plotting.Tests.csproj" />
3335
<Project Path="tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj" />

samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@
4040
<!-- Enables analyzers for this project (this is required since ProjectReference is not transitive). -->
4141
<ProjectReference Include="..\..\src\BenchmarkDotNet.Analyzers\BenchmarkDotNet.Analyzers.csproj" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
4242
</ItemGroup>
43+
4344
<Import Project="..\..\build\common.targets" />
4445
</Project>

samples/Directory.Build.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<Project>
2+
<!-- Manually import `BenchmarkDotNet.targets` for build that using ProjectReference -->
3+
<Import Project="$(MSBuildThisFileDirectory)..\src\BenchmarkDotNet\BenchmarkDotNet.targets" />
4+
</Project>

src/BenchmarkDotNet/BenchmarkDotNet.targets

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<Project>
1+
<Project>
22

33
<PropertyGroup>
44
<!-- If the RuntimeIdentifier is explicitly specified. Use the specified target platform. -->
55
<BenchmarkDotNetTargetPlatform>$(RuntimeIdentifier)</BenchmarkDotNetTargetPlatform>
66
</PropertyGroup>
7-
7+
88
<PropertyGroup Condition="'$(BenchmarkDotNetTargetPlatform)' == ''">
99
<!-- If RuntimeIdentifier is not specified Use current build platform -->
1010
<!-- List of runtimes supported by Gee.External.Capstone: https://github.com/9ee1/Capstone.NET/tree/master/Gee.External.Capstone/runtimes -->
@@ -18,7 +18,7 @@
1818
<BenchmarkDotNetTargetPlatform Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">$(BenchmarkDotNetTargetPlatform)-arm64</BenchmarkDotNetTargetPlatform>
1919
</PropertyGroup>
2020

21-
<Target Name="FilterBenchmarkDotNetPackageAssets" AfterTargets="ResolvePackageAssets">
21+
<Target Name="BdnFilterPackageAssets" AfterTargets="ResolvePackageAssets">
2222
<!-- Remove `runtimes/{RuntimeIdentifier}` files that is not matched to target platform. -->
2323
<ItemGroup Condition="'$(BenchmarkDotNetTargetPlatform)' != '' AND $(BenchmarkDotNetTargetPlatform) != 'all'">
2424
<RuntimeTargetsCopyLocalItems Remove="@(RuntimeTargetsCopyLocalItems)"
@@ -27,8 +27,21 @@
2727

2828
<!-- Remove unnecessary satellite assemblies. -->
2929
<ItemGroup>
30-
<ResourceCopyLocalItems Remove="@(ResourceCopyLocalItems)"
31-
Condition="'%(ResourceCopyLocalItems.NuGetPackageId)' == 'Microsoft.CodeAnalysis.Common' OR '%(ResourceCopyLocalItems.NuGetPackageId)' == 'Microsoft.CodeAnalysis.CSharp'"/>
30+
<ResourceCopyLocalItems
31+
Remove="@(ResourceCopyLocalItems)"
32+
Condition="'%(ResourceCopyLocalItems.NuGetPackageId)' == 'Microsoft.CodeAnalysis.Common'
33+
OR
34+
'%(ResourceCopyLocalItems.NuGetPackageId)' == 'Microsoft.CodeAnalysis.CSharp'
35+
OR
36+
'%(ResourceCopyLocalItems.NuGetPackageId)' == 'Microsoft.TestPlatform.AdapterUtilities'
37+
OR
38+
'%(ResourceCopyLocalItems.NuGetPackageId)' == 'Microsoft.TestPlatform.ObjectModel'
39+
OR
40+
'%(ResourceCopyLocalItems.NuGetPackageId)' == 'Microsoft.TestPlatform.TestHost'
41+
OR
42+
'%(ResourceCopyLocalItems.NuGetPackageId)' == 'Microsoft.TestPlatform.TranslationLayer'
43+
"/>
3244
</ItemGroup>
3345
</Target>
46+
3447
</Project>

tests/Directory.Build.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<Project>
2+
<!-- Manually import `BenchmarkDotNet.targets` for build that using ProjectReference -->
3+
<Import Project="$(MSBuildThisFileDirectory)..\src\BenchmarkDotNet\BenchmarkDotNet.targets" />
4+
</Project>

0 commit comments

Comments
 (0)