From eee26758c2e111c53c43eaffc6603039b97c102e Mon Sep 17 00:00:00 2001
From: am11 <3840695+am11@users.noreply.github.com>
Date: Mon, 26 Oct 2026 18:04:16 +0200
Subject: [PATCH 1/2] Trim OperatingSystem.IsXxx checks in library build
---
eng/RuntimeIdentifier.props | 18 +++++++++++++++
eng/illink.targets | 44 +++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+)
diff --git a/eng/RuntimeIdentifier.props b/eng/RuntimeIdentifier.props
index ea53b9e2d4e923..e2f854402c3364 100644
--- a/eng/RuntimeIdentifier.props
+++ b/eng/RuntimeIdentifier.props
@@ -69,6 +69,24 @@
true
true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<_ImportedRuntimeIdentifierProps>true
diff --git a/eng/illink.targets b/eng/illink.targets
index 714ac859810554..695be57bfbf175 100644
--- a/eng/illink.targets
+++ b/eng/illink.targets
@@ -192,6 +192,50 @@
+
+
+
+ <_OSSubstitutionsApply Condition="'$(TargetPlatformIdentifier)' != '' and
+ '$(TargetOS)' != '' and
+ '$(IsPackable)' != 'true' and
+ '$(BuildAllConfigurations)' != 'true' and
+ '$(ILLinkSubstitutionsLibraryBuildXml)' == '' and
+ ('$(TargetPlatformIdentifier)' == '$(TargetOS)' or
+ ('$(TargetPlatformIdentifier)' == 'unix' and '$(TargetsUnix)' == 'true') or
+ ('$(TargetPlatformIdentifier)' == 'linux' and '$(TargetsLinux)' == 'true') or
+ ('$(TargetPlatformIdentifier)' == 'ios' and ('$(TargetsiOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true')) or
+ ('$(TargetPlatformIdentifier)' == 'tvos' and '$(TargetstvOS)' == 'true'))">true
+
+
+
+
+ $(IntermediateOutputPath)ILLink.Substitutions.OperatingSystem.LibraryBuild.xml
+ <_OSSubstitutions>
+
+
+@(TargetOperatingSystemCheck->' ', '%0A')
+
+
+]]>
+
+
+
+
+
+
+
+
+
Date: Tue, 27 Oct 2026 14:38:29 +0200
Subject: [PATCH 2/2] Substitute OS checks for each flavor's own OS
---
eng/illink.targets | 42 +++++++++++++++++++++++++++++++-----------
1 file changed, 31 insertions(+), 11 deletions(-)
diff --git a/eng/illink.targets b/eng/illink.targets
index 695be57bfbf175..7cdbe7ffb079e2 100644
--- a/eng/illink.targets
+++ b/eng/illink.targets
@@ -195,32 +195,52 @@
+ Not applied to packages: binaries shipped in them (e.g. a runtimes/unix asset) must remain valid on every
+ OS that their flavor covers. -->
- <_OSSubstitutionsApply Condition="'$(TargetPlatformIdentifier)' != '' and
- '$(TargetOS)' != '' and
+ <_OSSubstitutionsFlavorMatchesTargetOS Condition="'$(TargetOS)' != '' and
+ ('$(TargetPlatformIdentifier)' == '$(TargetOS)' or
+ ('$(TargetPlatformIdentifier)' == 'unix' and '$(TargetsUnix)' == 'true') or
+ ('$(TargetPlatformIdentifier)' == 'linux' and '$(TargetsLinux)' == 'true') or
+ ('$(TargetPlatformIdentifier)' == 'ios' and ('$(TargetsiOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true')) or
+ ('$(TargetPlatformIdentifier)' == 'tvos' and '$(TargetstvOS)' == 'true'))">true
+
+ <_OSSubstitutionsTargetOS Condition="'$(_OSSubstitutionsFlavorMatchesTargetOS)' == 'true'">$(TargetOS)
+ <_OSSubstitutionsTargetOS Condition="'$(_OSSubstitutionsFlavorMatchesTargetOS)' != 'true' and '$(TargetPlatformIdentifier)' != 'unix'">$(TargetPlatformIdentifier.ToLowerInvariant())
+ <_OSSubstitutionsApply Condition="'$(_OSSubstitutionsTargetOS)' != '' and
'$(IsPackable)' != 'true' and
'$(BuildAllConfigurations)' != 'true' and
- '$(ILLinkSubstitutionsLibraryBuildXml)' == '' and
- ('$(TargetPlatformIdentifier)' == '$(TargetOS)' or
- ('$(TargetPlatformIdentifier)' == 'unix' and '$(TargetsUnix)' == 'true') or
- ('$(TargetPlatformIdentifier)' == 'linux' and '$(TargetsLinux)' == 'true') or
- ('$(TargetPlatformIdentifier)' == 'ios' and ('$(TargetsiOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true')) or
- ('$(TargetPlatformIdentifier)' == 'tvos' and '$(TargetstvOS)' == 'true'))">true
+ '$(ILLinkSubstitutionsLibraryBuildXml)' == ''">true
+
+
+
+ <_OSSubstitutionsCheck Include="@(TargetOperatingSystemCheck)" />
+
+
+
+
+
+
+
$(IntermediateOutputPath)ILLink.Substitutions.OperatingSystem.LibraryBuild.xml
<_OSSubstitutions>
-@(TargetOperatingSystemCheck->' ', '%0A')
+@(_OSSubstitutionsCheck->' ', '%0A')
]]>