Directory.Build.targets.in 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <Project>
  2. <PropertyGroup>
  3. <!-- Workaround while there is no SDK available that understands the TFM; suppress unsupported version errors. -->
  4. <NETCoreAppMaximumVersion>99.9</NETCoreAppMaximumVersion>
  5. <UpdateAspNetCoreKnownFramework
  6. Condition=" '$(UpdateAspNetCoreKnownFramework)' == '' ">true</UpdateAspNetCoreKnownFramework>
  7. </PropertyGroup>
  8. <!-- Workaround when there is no vNext SDK available; copy known apphost/framework reference info from 8.0. -->
  9. <ItemGroup>
  10. <KnownAppHostPack
  11. Include="@(KnownAppHostPack->WithMetadataValue('TargetFramework', 'net8.0'))"
  12. TargetFramework="${DefaultNetCoreTargetFramework}"
  13. Condition="'@(KnownAppHostPack->Count())' != '0' AND
  14. !(@(KnownAppHostPack->AnyHaveMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}')))" />
  15. <KnownRuntimePack
  16. Include="@(KnownRuntimePack->WithMetadataValue('TargetFramework', 'net8.0'))"
  17. TargetFramework="${DefaultNetCoreTargetFramework}"
  18. Condition="'@(KnownRuntimePack->Count())' != '0' AND
  19. !(@(KnownRuntimePack->AnyHaveMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}')))" />
  20. <KnownFrameworkReference
  21. Include="@(KnownFrameworkReference->WithMetadataValue('TargetFramework', 'net8.0'))"
  22. TargetFramework="${DefaultNetCoreTargetFramework}"
  23. Condition="'@(KnownFrameworkReference->Count())' != '0' AND
  24. !(@(KnownFrameworkReference->AnyHaveMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}')))" />
  25. <KnownILLinkPack
  26. Include="@(KnownILLinkPack->WithMetadataValue('TargetFramework', 'net8.0'))"
  27. TargetFramework="${DefaultNetCoreTargetFramework}"
  28. Condition="'@(KnownILLinkPack->Count())' != '0' AND
  29. !(@(KnownILLinkPack->AnyHaveMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}')))" />
  30. <KnownILCompilerPack
  31. Include="@(KnownILCompilerPack->WithMetadataValue('TargetFramework', 'net8.0'))"
  32. TargetFramework="${DefaultNetCoreTargetFramework}"
  33. Condition="'@(KnownILCompilerPack->Count())' != '0' AND
  34. !(@(KnownILCompilerPack->AnyHaveMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}')))" />
  35. <KnownWebAssemblySdkPack
  36. Include="@(KnownWebAssemblySdkPack->WithMetadataValue('TargetFramework', 'net8.0'))"
  37. TargetFramework="${DefaultNetCoreTargetFramework}"
  38. Condition="'@(KnownWebAssemblySdkPack->Count())' != '0' AND
  39. !(@(KnownWebAssemblySdkPack->AnyHaveMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}')))" />
  40. </ItemGroup>
  41. <ItemGroup>
  42. <!--
  43. Reference base shared framework at incoming dependency flow version, not bundled sdk version.
  44. Apply this to all projects that target the default tfm (e.g. net8.0) or a rid-based variant of it (e.g. net8.0-windows)
  45. -->
  46. <FrameworkReference
  47. Update="Microsoft.NETCore.App"
  48. Condition=" (('$(ProjectTargetFrameworkIdentifier)' == '${DefaultNetCoreTargetFramework}') AND '${DefaultNetCoreTargetFramework}' == '$(ProjectTargetFrameworkVersion)') AND '$(TargetLatestDotNetRuntime)' != 'false' "
  49. RuntimeFrameworkVersion="${MicrosoftNETCoreAppRuntimeVersion}"
  50. TargetingPackVersion="${MicrosoftNETCoreAppRefVersion}" />
  51. <PackageReference Include="Microsoft.DotNet.ILCompiler"
  52. Condition=" '$(PublishAot)' == 'true' "
  53. Version="${MicrosoftNETCoreAppRuntimeVersion}" />
  54. </ItemGroup>
  55. <ItemGroup>
  56. <!-- Use the same NETCore shared framework as repo built against except when building product code in servicing. -->
  57. <KnownFrameworkReference Update="Microsoft.NETCore.App">
  58. <LatestRuntimeFrameworkVersion
  59. Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftNETCoreAppRuntimeVersion}</LatestRuntimeFrameworkVersion>
  60. <TargetingPackVersion
  61. Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftNETCoreAppRefVersion}</TargetingPackVersion>
  62. <!--
  63. Change the default shared framework version only when _not_ servicing. Avoid bumping version used in most
  64. projects. When servicing, projects (Microsoft.AspNetCore.App.Runtime in particular) can use
  65. $(TargetLatestRuntimePatch) to explicitly control whether assemblies build against default (false) or
  66. latest (true). When that property is not set, SDK uses default metadata in most cases but published apps
  67. e.g. tool projects (again, property not set) use latest.
  68. On the other hand, $(TargetLatestDotNetRuntime) is specific to this repo and controls only the update below.
  69. -->
  70. <DefaultRuntimeFrameworkVersion Condition=" '$(IsServicingBuild)' != 'true' AND
  71. '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' AND
  72. '$(TargetLatestDotNetRuntime)' != 'false' ">${MicrosoftNETCoreAppRuntimeVersion}</DefaultRuntimeFrameworkVersion>
  73. <RuntimePackRuntimeIdentifiers Condition=" '$(DotNetBuildSourceOnly)' == 'true' ">$(TargetRuntimeIdentifier)</RuntimePackRuntimeIdentifiers>
  74. </KnownFrameworkReference>
  75. <KnownAppHostPack Update="Microsoft.NETCore.App">
  76. <AppHostPackVersion
  77. Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftNETCoreAppRuntimeVersion}</AppHostPackVersion>
  78. <AppHostRuntimeIdentifiers Condition=" '$(DotNetBuildSourceOnly)' == 'true' ">$(TargetRuntimeIdentifier)</AppHostRuntimeIdentifiers>
  79. </KnownAppHostPack>
  80. <KnownRuntimePack Update="Microsoft.NETCore.App">
  81. <LatestRuntimeFrameworkVersion
  82. Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftNETCoreAppRuntimeVersion}</LatestRuntimeFrameworkVersion>
  83. <AppHostRuntimeIdentifiers Condition=" '$(DotNetBuildSourceOnly)' == 'true' ">$(TargetRuntimeIdentifier)</AppHostRuntimeIdentifiers>
  84. </KnownRuntimePack>
  85. <KnownWebAssemblySdkPack Update="Microsoft.NET.Sdk.WebAssembly.Pack">
  86. <WebAssemblySdkPackVersion
  87. Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftNETCoreAppRuntimeVersion}</WebAssemblySdkPackVersion>
  88. </KnownWebAssemblySdkPack>
  89. <KnownCrossgen2Pack Update="Microsoft.NETCore.App.Crossgen2" Condition=" '$(DotNetBuildSourceOnly)' == 'true' ">
  90. <Crossgen2PackVersion
  91. Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftNETCoreAppRuntimeVersion}</Crossgen2PackVersion>
  92. <Crossgen2RuntimeIdentifiers>$(TargetRuntimeIdentifier)</Crossgen2RuntimeIdentifiers>
  93. </KnownCrossgen2Pack>
  94. <KnownILLinkPack Update="Microsoft.NET.ILLink.Tasks" Condition=" '$(DotNetBuildSourceOnly)' == 'true' ">
  95. <ILLinkPackVersion
  96. Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftNETCoreAppRuntimeVersion}</ILLinkPackVersion>
  97. </KnownILLinkPack>
  98. <!-- Use the just-built ASP.NET Core shared framework if available except when building product code in servicing. -->
  99. <KnownFrameworkReference Update="Microsoft.AspNetCore.App" Condition=" $(UpdateAspNetCoreKnownFramework) ">
  100. <LatestRuntimeFrameworkVersion
  101. Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftAspNetCoreAppRuntimeVersion}</LatestRuntimeFrameworkVersion>
  102. <RuntimePackRuntimeIdentifiers
  103. Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${SupportedRuntimeIdentifiers}</RuntimePackRuntimeIdentifiers>
  104. <!-- Do not update %(TargetingPackVersion) until X.Y.0 versions have been released. -->
  105. <TargetingPackVersion
  106. Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' AND '${AspNetCorePatchVersion}' != '1' ">${MicrosoftAspNetCoreAppRefVersion}</TargetingPackVersion>
  107. <DefaultRuntimeFrameworkVersion Condition=" '$(IsServicingBuild)' != 'true' AND
  108. '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftAspNetCoreAppRuntimeVersion}</DefaultRuntimeFrameworkVersion>
  109. </KnownFrameworkReference>
  110. </ItemGroup>
  111. <!-- When building and running locally, manually resolve the just-built frameworks. On Helix, let the SDK resolve the packs itself (they're laid out on top of the .NET SDK in the work items) -->
  112. <PropertyGroup Condition="$(UpdateAspNetCoreKnownFramework) and '$(HELIX_CORRELATION_PAYLOAD)' == ''">
  113. <!-- Allow additional targeting and runtime packs to be downloaded only if required by a test. -->
  114. <EnableTargetingPackDownload Condition="'$(TestRequiresTargetingPackDownload)' != 'true'">false</EnableTargetingPackDownload>
  115. <EnableRuntimePackDownload Condition="'$(TestRequiresRuntimePackDownload)' != 'true'">false</EnableRuntimePackDownload>
  116. <GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
  117. </PropertyGroup>
  118. <Target Name="ResolveLiveBuiltAspnetCoreKnownFramework" Condition="$(UpdateAspNetCoreKnownFramework) and '$(HELIX_CORRELATION_PAYLOAD)' == ''" AfterTargets="ResolveFrameworkReferences">
  119. <Error Text="Requested Microsoft.AspNetCore.App v${MicrosoftAspNetCoreAppRefVersion} ref pack does not exist."
  120. Condition="!Exists('$(TargetingPackLayoutRoot)packs\Microsoft.AspNetCore.App.Ref\${MicrosoftAspNetCoreAppRefVersion}\data\FrameworkList.xml') " />
  121. <ItemGroup>
  122. <ResolvedTargetingPack Path="$(TargetingPackLayoutRoot)packs\Microsoft.AspNetCore.App.Ref\${MicrosoftAspNetCoreAppRefVersion}"
  123. NugetPackageVersion="${MicrosoftAspNetCoreAppRefVersion}"
  124. PackageDirectory="$(TargetingPackLayoutRoot)packs\Microsoft.AspNetCore.App.Ref\${MicrosoftAspNetCoreAppRefVersion}"
  125. Condition="'%(ResolvedTargetingPack.RuntimeFrameworkName)' == 'Microsoft.AspNetCore.App'" />
  126. <ResolvedRuntimePack PackageDirectory="$(SharedFrameworkLayoutRoot)shared\Microsoft.AspNetCore.App\${MicrosoftAspNetCoreAppRuntimeVersion}"
  127. Condition="'%(ResolvedRuntimePack.RuntimeFrameworkName)' == 'Microsoft.AspNetCore.App'" />
  128. <ResolvedFrameworkReference TargetingPackPath="$(TargetingPackLayoutRoot)packs\Microsoft.AspNetCore.App.Ref\${MicrosoftAspNetCoreAppRefVersion}"
  129. TargetingPackVersion="${MicrosoftAspNetCoreAppRefVersion}"
  130. RuntimePackPath="$(SharedFrameworkLayoutRoot)shared\Microsoft.AspNetCore.App\${MicrosoftAspNetCoreAppRuntimeVersion}"
  131. Condition="'%(Identity)' == 'Microsoft.AspNetCore.App'" />
  132. </ItemGroup>
  133. </Target>
  134. <!--
  135. Make a netstandard2.1 copy of the .net ILLinkPack to work around a trimming issue.
  136. See https://github.com/dotnet/linker/issues/3175
  137. -->
  138. <Target Name="_FixKnownILLinkPack"
  139. BeforeTargets="ProcessFrameworkReferences">
  140. <ItemGroup>
  141. <KnownILLinkPack Include="@(KnownILLinkPack)"
  142. Condition="'%(TargetFramework)' == 'net7.0'"
  143. TargetFramework="netstandard2.1"
  144. ILLinkPackVersion="%(KnownILLinkPack.ILLinkPackVersion)" />
  145. </ItemGroup>
  146. </Target>
  147. </Project>