Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
0c571ad
Initial plan
Copilot Feb 4, 2026
9fd6d9d
Add ComputeInstructionSet MSBuild task and integration
Copilot Feb 4, 2026
d88ee8e
Add unit tests for ComputeInstructionSet task
Copilot Feb 4, 2026
a16b479
Address code review feedback
Copilot Feb 4, 2026
fba943a
Auto-format source code
Feb 4, 2026
bb17758
Add documentation comments with links to sources for device/CPU/instr…
Copilot Feb 4, 2026
bb62425
Add RuntimeIdentifier input to ComputeInstructionSet task for macOS/M…
Copilot Feb 5, 2026
f307019
Improve RuntimeIdentifier parsing to handle versioned RIDs
Copilot Feb 5, 2026
6585fc1
Fix crossgen2 instruction set argument format (use space instead of c…
Copilot Feb 5, 2026
5731c82
Prevent duplicate instruction set arguments by checking if already pr…
Copilot Feb 6, 2026
daa9e44
Use colon separator for --instruction-set argument (MSBuild format)
Copilot Feb 9, 2026
f7b33cf
Address code review feedback: refactor dictionaries, add opt-out prop…
Copilot Feb 9, 2026
449bf91
Rename property, fix nullability, handle simulators, add documentation
Copilot Feb 9, 2026
82285a0
Update expected siezs.
rolfbjarne Feb 10, 2026
b6effee
Address final review feedback: update docs, add dependency, sort prop…
Copilot Feb 10, 2026
e0c0859
Remove SessionId property from target
Copilot Feb 11, 2026
37ff91d
Merge remote-tracking branch 'origin/net11.0' into copilot/add-instru…
rolfbjarne Feb 11, 2026
266f35b
Merge remote-tracking branch 'origin/net11.0' into copilot/add-instru…
rolfbjarne Feb 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/building-apps/build-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,27 @@ By default we require a provisioning profile if:

Setting this property to `true` or `false` will override the default logic.

## ComputeInstructionSetForReadyToRun

Controls whether to automatically compute and pass the instruction set to the ReadyToRun (R2R) compiler based on the deployment target.

When `PublishReadyToRun` is `true`, the build system automatically computes the minimum CPU instruction set required based on:
* The `SupportedOSPlatformVersion` (minimum OS version the app supports)
* The `RuntimeIdentifier` (target architecture and platform)

This computed instruction set is then passed to crossgen2 via the `--instruction-set` argument, enabling the R2R compiler to generate optimized native code using appropriate CPU instructions.

Set this property to `false` to disable automatic instruction set computation and use crossgen2's default behavior.

Default: `true`

Example:
```xml
<PropertyGroup>
<ComputeInstructionSetForReadyToRun>false</ComputeInstructionSetForReadyToRun>
</PropertyGroup>
```

## CompressBindingResourcePackage

The native references in a binding projects are copied to the output directory during the build process, next to the binding assembly (into something we call a "binding resource package").
Expand Down
27 changes: 27 additions & 0 deletions dotnet/targets/Microsoft.Sdk.R2R.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Xamarin.MacDev.Tasks.ComputeInstructionSet" AssemblyFile="$(_XamarinTaskAssembly)" />

<!-- Workaround until https://github.com/dotnet/sdk/pull/52480 is merged -->
<Target Name="_LinkReadyToRunMachO">
<Message Text="Skipped built-in dylib creation" />
Expand All @@ -14,6 +16,31 @@
</ItemGroup>
</Target>

<!--
Compute the instruction set for R2R/NAOT compilation based on the SupportedOSPlatformVersion and RuntimeIdentifier.
This target runs early in the build to set PublishReadyToRunCrossgen2ExtraArgs if needed.
Set ComputeInstructionSetForReadyToRun to false to opt out of this computation.
-->
<Target Name="_ComputeInstructionSetForCrossgen2"
Condition="'$(PublishReadyToRun)' == 'true' And '$(ComputeInstructionSetForReadyToRun)' != 'false'"
DependsOnTargets="_DetectSdkLocations"
BeforeTargets="ResolveReadyToRunCompilers">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a dependency on the "_DetectSdkLocations" task.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Added DependsOnTargets="_DetectSdkLocations" to the target. (commit b6effee)

<ComputeInstructionSet
RuntimeIdentifier="$(RuntimeIdentifier)"
SdkDevPath="$(_SdkDevPath)"
SupportedOSPlatformVersion="$(SupportedOSPlatformVersion)"
TargetFrameworkMoniker="$(TargetFramework)"
>
<Output TaskParameter="InstructionSet" PropertyName="_ComputedInstructionSet" />
</ComputeInstructionSet>

<PropertyGroup Condition="'$(_ComputedInstructionSet)' != ''">
<!-- Append the instruction set to the existing PublishReadyToRunCrossgen2ExtraArgs, but only if not already present -->
<PublishReadyToRunCrossgen2ExtraArgs Condition="'$(PublishReadyToRunCrossgen2ExtraArgs)' == ''">--instruction-set:$(_ComputedInstructionSet)</PublishReadyToRunCrossgen2ExtraArgs>
<PublishReadyToRunCrossgen2ExtraArgs Condition="'$(PublishReadyToRunCrossgen2ExtraArgs)' != '' And !$(PublishReadyToRunCrossgen2ExtraArgs.Contains('--instruction-set'))">$(PublishReadyToRunCrossgen2ExtraArgs) --instruction-set:$(_ComputedInstructionSet)</PublishReadyToRunCrossgen2ExtraArgs>
</PropertyGroup>
</Target>

<!-- Pluck R2R's object files from @(ResolvedFileToPublish) so that we can link them into a .dylib or .framework -->
<Target Name="_CollectR2RObjectFilesForLinking">
<ItemGroup>
Expand Down
Loading
Loading