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..7cdbe7ffb079e2 100644
--- a/eng/illink.targets
+++ b/eng/illink.targets
@@ -192,6 +192,70 @@
+
+
+
+ <_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)' == ''">true
+
+
+
+
+
+
+ <_OSSubstitutionsCheck Include="@(TargetOperatingSystemCheck)" />
+
+
+
+
+
+
+
+
+ $(IntermediateOutputPath)ILLink.Substitutions.OperatingSystem.LibraryBuild.xml
+ <_OSSubstitutions>
+
+
+@(_OSSubstitutionsCheck->' ', '%0A')
+
+
+]]>
+
+
+
+
+
+
+
+
+