Commit 7cad308
authored
[msbuild] refactor
* [msbuild] refactor `BenchmarkDotNet.Weaver.targets` to support mobile platforms
Context: dotnet#2929
Context: https://github.com/dotnet/android/blob/4aa9af89102af2e745a8507992187d3c5993d638/Documentation/guides/MSBuildBestPractices.md
In initially testing BenchmarkDotNet with .NET MAUI, I found that the
weaver was not being executed because the `Publish` target is not
called during the build process for Android and iOS projects. I think
the target could actually run much sooner during builds and achieve
better results.
To address this, I refactored the `BenchmarkDotNet.Weaver.targets`
file to run after `CoreCompile` on the `@(IntermediateAssembly)` in
the `obj` directory. This is similar to what other targets do, such as
the XamlC compiler:
https://github.com/dotnet/maui/blob/8224becbb3a8a6bb1caaca4bbe70c56e88875506/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets#L213-L255
Other general MSBuild improvements:
* Defined an MSBuild property for everything that seems useful. This
allows consuming projects to configure the behavior (or
workarounds!) as needed.
* Made the MSBuild target incremental by using inputs and outputs. If
the `.dll` file is an input, we can write a `.stamp` file as an
output to indicate that the weaver has already been run for that
assembly. If the `.dll` file changes, the weaver will run again.
I tested this change with a .NET MAUI on 4 platforms and also the
existing `BenchmarkDotNet.Samples` console app.
* Prefix `BenchmarkDotNet`BenchmarkDotNet.Weaver.targets to support mobile platforms (dotnet#2931)1 parent 3db7350 commit 7cad308
File tree
1 file changed
+21
-7
lines changed- src/BenchmarkDotNet.Weaver/buildTransitive/netstandard2.0
1 file changed
+21
-7
lines changedLines changed: 21 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
10 | 21 | | |
11 | | - | |
12 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
13 | 27 | | |
14 | 28 | | |
0 commit comments