From 4f8c185817feb338e6dbc806f788e2f9f12b8cf5 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 23 Apr 2026 11:48:09 +0200 Subject: [PATCH 1/6] [msbuild/dotnet] Use 'SdkIsSimulator' instead of 'ComputedPlatform'. This simplifies the code, since we only have a single property as the source of truth whether we're building for the simulator or not. --- .../Xamarin.Shared.Sdk.DefaultItems.targets | 5 ---- dotnet/targets/Xamarin.Shared.Sdk.props | 4 +++ dotnet/targets/Xamarin.Shared.Sdk.targets | 4 +-- msbuild/Xamarin.Shared/Xamarin.Shared.props | 26 +++---------------- msbuild/Xamarin.Shared/Xamarin.Shared.targets | 2 +- .../Xamarin.Shared/Xamarin.iOS.Common.targets | 6 ++--- .../Xamarin.iOS.Common.After.targets | 4 +-- tests/ComputeRegistrarConstant.targets | 2 +- tests/monotouch-test/dotnet/shared.csproj | 2 +- 9 files changed, 17 insertions(+), 38 deletions(-) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets b/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets index b970adc12d0d..973f26394330 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets @@ -59,11 +59,6 @@ - - iPhoneSimulator - iPhone - - <_RuntimeFrameworkVersion>$(BundledNETCorePlatformsPackageVersion) <_RuntimeFrameworkVersion Condition="'$(CUSTOM_DOTNET_VERSION)' != ''">$(CUSTOM_DOTNET_VERSION) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.props b/dotnet/targets/Xamarin.Shared.Sdk.props index 039ef3a54e21..47171a23b6f8 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.props +++ b/dotnet/targets/Xamarin.Shared.Sdk.props @@ -147,6 +147,10 @@ <_SdkIsSimulator Condition="'$(_SdkIsSimulator)' == ''">false $(_SdkIsSimulator) + + + iPhoneSimulator + iPhone diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index 019e7fda263a..358e560da8aa 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -1255,14 +1255,14 @@ <_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == '' And '$(_PlatformName)' == 'MacCatalyst'">static - <_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == '' And ('$(ComputedPlatform)' != 'iPhone' Or '$(_PlatformName)' == 'macOS')">dylib + <_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == '' And ('$(SdkIsSimulator)' == 'true' Or '$(_PlatformName)' == 'macOS')">dylib <_LibMonoLinkMode Condition="'$(_LibMonoLinkMode)' == ''">static <_LibMonoExtension Condition="'$(_LibMonoLinkMode)' == 'dylib'">dylib <_LibMonoExtension Condition="'$(_LibMonoLinkMode)' == 'static'">a <_LibXamarinLinkMode Condition="'$(_LibXamarinLinkMode)' == '' And '$(_PlatformName)' == 'MacCatalyst'">static - <_LibXamarinLinkMode Condition="'$(_LibXamarinLinkMode)' == '' And '$(ComputedPlatform)' != 'iPhone' And '$(_PlatformName)' != 'macOS'">dylib + <_LibXamarinLinkMode Condition="'$(_LibXamarinLinkMode)' == '' And '$(SdkIsSimulator)' == 'true' And '$(_PlatformName)' != 'macOS'">dylib <_LibXamarinLinkMode Condition="'$(_LibXamarinLinkMode)' == ''">static <_LibXamarinExtension Condition="'$(_LibXamarinLinkMode)' == 'dylib'">dylib <_LibXamarinExtension Condition="'$(_LibXamarinLinkMode)' == 'static'">a diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.props b/msbuild/Xamarin.Shared/Xamarin.Shared.props index 4b2c9b8173b7..94ee2905ab3b 100644 --- a/msbuild/Xamarin.Shared/Xamarin.Shared.props +++ b/msbuild/Xamarin.Shared/Xamarin.Shared.props @@ -20,26 +20,6 @@ Copyright (C) 2020 Microsoft. All rights reserved. - - - $(Platform) - iPhone - - @@ -120,7 +100,7 @@ Copyright (C) 2020 Microsoft. All rights reserved. <_CanArchive>false <_CanArchive Condition="('$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst') And '$(OutputType)' == 'Exe' And '$(IsAppExtension)' == 'false'">true - <_CanArchive Condition="('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS' Or '$(_PlatformName)' == 'watchOS') And '$(OutputType)' == 'Exe' And '$(ComputedPlatform)' == 'iPhone' And '$(IsAppExtension)' == 'false' And '$(IsWatchApp)' == 'false'">true + <_CanArchive Condition="('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS' Or '$(_PlatformName)' == 'watchOS') And '$(OutputType)' == 'Exe' And '$(SdkIsSimulator)' != 'true' And '$(IsAppExtension)' == 'false' And '$(IsWatchApp)' == 'false'">true @@ -144,7 +124,7 @@ Copyright (C) 2020 Microsoft. All rights reserved. true true - true + true false @@ -153,7 +133,7 @@ Copyright (C) 2020 Microsoft. All rights reserved. true - true + true false diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.targets b/msbuild/Xamarin.Shared/Xamarin.Shared.targets index 7dfa76428c93..5ecee998dfb5 100644 --- a/msbuild/Xamarin.Shared/Xamarin.Shared.targets +++ b/msbuild/Xamarin.Shared/Xamarin.Shared.targets @@ -2658,7 +2658,7 @@ Copyright (C) 2018 Microsoft. All rights reserved. - @@ -124,7 +124,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved. /> - + - - + @@ -178,7 +178,7 @@ Copyright (C) 2011-2013 Xamarin. All rights reserved. - + diff --git a/tests/ComputeRegistrarConstant.targets b/tests/ComputeRegistrarConstant.targets index 9d5d2e9dcaf5..8660e48bd918 100644 --- a/tests/ComputeRegistrarConstant.targets +++ b/tests/ComputeRegistrarConstant.targets @@ -2,7 +2,7 @@ - true + true true diff --git a/tests/monotouch-test/dotnet/shared.csproj b/tests/monotouch-test/dotnet/shared.csproj index 282d2a42e265..214bc2945fbc 100644 --- a/tests/monotouch-test/dotnet/shared.csproj +++ b/tests/monotouch-test/dotnet/shared.csproj @@ -267,7 +267,7 @@ - $(DefineConstants);AOT + $(DefineConstants);AOT $(DefineConstants);AOT $(DefineConstants);AOT From 9095a9e03f8c059fd54e7164a2b5ea0426a49a63 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 30 Apr 2026 11:52:10 +0200 Subject: [PATCH 2/6] [msbuild] Address PR feedback: introduce SdkIsDevice property. Only set ComputedPlatform for iOS and tvOS (like the old behavior). Introduce a new SdkIsDevice property that's set to true when building for device (iOS and tvOS only), and use it to retain the original behavior of ComputedPlatform == 'iPhone' wherever needed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- dotnet/targets/Xamarin.Shared.Sdk.props | 7 +++++-- msbuild/Xamarin.Shared/Xamarin.Shared.props | 2 +- msbuild/Xamarin.Shared/Xamarin.Shared.targets | 2 +- msbuild/Xamarin.Shared/Xamarin.iOS.Common.targets | 6 +++--- .../Xamarin.iOS.Common.After.targets | 4 ++-- tests/monotouch-test/dotnet/shared.csproj | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.props b/dotnet/targets/Xamarin.Shared.Sdk.props index 47171a23b6f8..7ec4ade318eb 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.props +++ b/dotnet/targets/Xamarin.Shared.Sdk.props @@ -148,9 +148,12 @@ $(_SdkIsSimulator) + + true + - iPhoneSimulator - iPhone + iPhoneSimulator + iPhone diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.props b/msbuild/Xamarin.Shared/Xamarin.Shared.props index 94ee2905ab3b..aa4c7ac5331e 100644 --- a/msbuild/Xamarin.Shared/Xamarin.Shared.props +++ b/msbuild/Xamarin.Shared/Xamarin.Shared.props @@ -100,7 +100,7 @@ Copyright (C) 2020 Microsoft. All rights reserved. <_CanArchive>false <_CanArchive Condition="('$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst') And '$(OutputType)' == 'Exe' And '$(IsAppExtension)' == 'false'">true - <_CanArchive Condition="('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS' Or '$(_PlatformName)' == 'watchOS') And '$(OutputType)' == 'Exe' And '$(SdkIsSimulator)' != 'true' And '$(IsAppExtension)' == 'false' And '$(IsWatchApp)' == 'false'">true + <_CanArchive Condition="('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS' Or '$(_PlatformName)' == 'watchOS') And '$(OutputType)' == 'Exe' And '$(SdkIsDevice)' == 'true' And '$(IsAppExtension)' == 'false' And '$(IsWatchApp)' == 'false'">true diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.targets b/msbuild/Xamarin.Shared/Xamarin.Shared.targets index 3929a5dd9f62..0483bfd1a734 100644 --- a/msbuild/Xamarin.Shared/Xamarin.Shared.targets +++ b/msbuild/Xamarin.Shared/Xamarin.Shared.targets @@ -2658,7 +2658,7 @@ Copyright (C) 2018 Microsoft. All rights reserved. - @@ -124,7 +124,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved. /> - + - - + @@ -178,7 +178,7 @@ Copyright (C) 2011-2013 Xamarin. All rights reserved. - + diff --git a/tests/monotouch-test/dotnet/shared.csproj b/tests/monotouch-test/dotnet/shared.csproj index 214bc2945fbc..37437089b7fe 100644 --- a/tests/monotouch-test/dotnet/shared.csproj +++ b/tests/monotouch-test/dotnet/shared.csproj @@ -267,7 +267,7 @@ - $(DefineConstants);AOT + $(DefineConstants);AOT $(DefineConstants);AOT $(DefineConstants);AOT From da7ac40ae50059da4735fd3be8c35e25116e83ea Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 30 Apr 2026 12:12:01 +0200 Subject: [PATCH 3/6] tweaks --- dotnet/targets/Xamarin.Shared.Sdk.props | 4 ++-- msbuild/Xamarin.Shared/Xamarin.Shared.props | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.props b/dotnet/targets/Xamarin.Shared.Sdk.props index 7ec4ade318eb..ae5137fbbf76 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.props +++ b/dotnet/targets/Xamarin.Shared.Sdk.props @@ -152,8 +152,8 @@ true - iPhoneSimulator - iPhone + iPhoneSimulator + iPhone diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.props b/msbuild/Xamarin.Shared/Xamarin.Shared.props index aa4c7ac5331e..5550e99280e9 100644 --- a/msbuild/Xamarin.Shared/Xamarin.Shared.props +++ b/msbuild/Xamarin.Shared/Xamarin.Shared.props @@ -97,10 +97,10 @@ Copyright (C) 2020 Microsoft. All rights reserved. - + <_CanArchive>false <_CanArchive Condition="('$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst') And '$(OutputType)' == 'Exe' And '$(IsAppExtension)' == 'false'">true - <_CanArchive Condition="('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS' Or '$(_PlatformName)' == 'watchOS') And '$(OutputType)' == 'Exe' And '$(SdkIsDevice)' == 'true' And '$(IsAppExtension)' == 'false' And '$(IsWatchApp)' == 'false'">true + <_CanArchive Condition="'$(OutputType)' == 'Exe' And '$(SdkIsDevice)' == 'true' And '$(IsAppExtension)' == 'false'">true @@ -124,7 +124,7 @@ Copyright (C) 2020 Microsoft. All rights reserved. true true - true + true false @@ -133,7 +133,7 @@ Copyright (C) 2020 Microsoft. All rights reserved. true - true + true false From 668d8c87a7d2433a2809fefa7c8dfd427c2475cf Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 30 Apr 2026 12:16:47 +0200 Subject: [PATCH 4/6] [docs] Document the new SdkIsDevice property. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/building-apps/build-properties.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/building-apps/build-properties.md b/docs/building-apps/build-properties.md index e6ab2cbe3667..95a3f4857f39 100644 --- a/docs/building-apps/build-properties.md +++ b/docs/building-apps/build-properties.md @@ -1268,6 +1268,19 @@ However, the either of the following works: Note: this property will always be `false` on macOS and Mac Catalyst. +## SdkIsDevice + +This property is a read-only property (setting it will have no effect) that +specifies whether we're building for a device or not. + +This property is only `true` when building for an iOS or tvOS device (i.e., +when `SdkIsSimulator` is not `true` and the platform is iOS or tvOS). It is +not set for macOS or Mac Catalyst builds. + +Like `SdkIsSimulator`, this property is only set after [imports and +properties](/visualstudio/msbuild/build-process-overview#evaluate-imports-and-properties) +have been evaluated. + ## StripPath The full path to the `strip` command-line tool. From 15c81d25ef5aa56925aa54425b5753ff14aaf091 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 30 Apr 2026 12:17:22 +0200 Subject: [PATCH 5/6] [docs] Add instruction to check docs/ when making changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/copilot-instructions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 570b20cbd2ba..4cb9965eaa88 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -156,6 +156,7 @@ Common project structure for Apple platform apps: 2. Run `make` to rebuild affected components 3. Test changes using appropriate test suite 4. Verify on both simulator and device when possible +5. Check if the documentation in the `docs/` directory needs to be updated to reflect the changes (e.g. new MSBuild properties should be documented in `docs/building-apps/build-properties.md`) ### Code Style From 1892441b883e37c2506a4f342cd2781d376d2e42 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 30 Apr 2026 12:18:12 +0200 Subject: [PATCH 6/6] [docs] Sort SdkIsDevice before SdkIsSimulator alphabetically. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/building-apps/build-properties.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/building-apps/build-properties.md b/docs/building-apps/build-properties.md index 95a3f4857f39..ab6a1742229a 100644 --- a/docs/building-apps/build-properties.md +++ b/docs/building-apps/build-properties.md @@ -1234,6 +1234,19 @@ $ dotnet run -p:StandardInputPath=stdin.txt Note: this can also be accomplished by passing `--stdin ...` using the [OpenArguments](#openarguments) property. +## SdkIsDevice + +This property is a read-only property (setting it will have no effect) that +specifies whether we're building for a device or not. + +This property is only `true` when building for an iOS or tvOS device (i.e., +when `SdkIsSimulator` is not `true` and the platform is iOS or tvOS). It is +not set for macOS or Mac Catalyst builds. + +Like `SdkIsSimulator`, this property is only set after [imports and +properties](/visualstudio/msbuild/build-process-overview#evaluate-imports-and-properties) +have been evaluated. + ## SdkIsSimulator This property is a read-only property (setting it will have no effect) that @@ -1268,19 +1281,6 @@ However, the either of the following works: Note: this property will always be `false` on macOS and Mac Catalyst. -## SdkIsDevice - -This property is a read-only property (setting it will have no effect) that -specifies whether we're building for a device or not. - -This property is only `true` when building for an iOS or tvOS device (i.e., -when `SdkIsSimulator` is not `true` and the platform is iOS or tvOS). It is -not set for macOS or Mac Catalyst builds. - -Like `SdkIsSimulator`, this property is only set after [imports and -properties](/visualstudio/msbuild/build-process-overview#evaluate-imports-and-properties) -have been evaluated. - ## StripPath The full path to the `strip` command-line tool.