Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Fixes: #2910

Copilot was able to automate much of this. I got "nerd sniped" to fix some of the issues I found along the way.

There are some fixes required for iOS and Android to work, I will send in separate PRs.

Fixes: dotnet#2910

Copilot was able to automate much of this. I got "nerd sniped" to fix
some of the issues I found along the way.

There are some fixes required for iOS and Android to work, I will send
in separate PRs.
jonathanpeppers added a commit to jonathanpeppers/BenchmarkDotNet that referenced this pull request Dec 16, 2025
Context: dotnet#2929

Without this fix, I was getting the exception on `net10.0-ios` and
`net10.0-maccatalyst` projects:

    Access to the path '~/src/dotnet/BenchmarkDotNet/samples/BenchmarkDotNet.Samples.Maui/bin/Debug/net10.0-maccatalyst/maccatalyst-arm64/BenchmarkDotNet.Samples.Maui.app/BenchmarkDotNet.Artifacts' is denied.

This change was already here for Android, but it feels like it should
have been here for iOS as well.

`net10.0-maccatalyst` will also respond to this fix, as it is basically
iOS "emulated" on macOS.
jonathanpeppers added a commit to jonathanpeppers/BenchmarkDotNet that referenced this pull request Dec 16, 2025
… 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.
timcassell pushed a commit that referenced this pull request Dec 16, 2025
Context: #2929

Without this fix, I was getting the exception on `net10.0-ios` and
`net10.0-maccatalyst` projects:

    Access to the path '~/src/dotnet/BenchmarkDotNet/samples/BenchmarkDotNet.Samples.Maui/bin/Debug/net10.0-maccatalyst/maccatalyst-arm64/BenchmarkDotNet.Samples.Maui.app/BenchmarkDotNet.Artifacts' is denied.

This change was already here for Android, but it feels like it should
have been here for iOS as well.

`net10.0-maccatalyst` will also respond to this fix, as it is basically
iOS "emulated" on macOS.
@timcassell timcassell merged commit 3db7350 into dotnet:master Dec 16, 2025
11 checks passed
@timcassell timcassell added this to the v0.16.0 milestone Dec 16, 2025
timcassell pushed a commit that referenced this pull request Dec 16, 2025
… platforms (#2931)

* [msbuild] refactor `BenchmarkDotNet.Weaver.targets` to support mobile platforms

Context: #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`
@adamsitnik
Copy link
Member

@jonathanpeppers thanks a lot for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop Xamarin sample files

3 participants