Directory.Build.targets.in 5.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 6.0. -->
  9. <ItemGroup>
  10. <KnownAppHostPack
  11. Include="@(KnownAppHostPack->WithMetadataValue('TargetFramework', 'net6.0'))"
  12. TargetFramework="${DefaultNetCoreTargetFramework}"
  13. Condition="@(KnownAppHostPack->Count()) != '0' AND
  14. !(@(KnownAppHostPack->AnyHaveMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}')))" />
  15. <KnownFrameworkReference
  16. Include="@(KnownFrameworkReference->WithMetadataValue('TargetFramework', 'net6.0'))"
  17. TargetFramework="${DefaultNetCoreTargetFramework}"
  18. Condition="@(KnownFrameworkReference->Count()) != '0' AND
  19. !(@(KnownFrameworkReference->AnyHaveMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}')))" />
  20. </ItemGroup>
  21. <ItemGroup>
  22. <!-- Use the same NETCore shared framework as repo built against except when building product code in servicing. -->
  23. <KnownFrameworkReference
  24. Update="@(KnownFrameworkReference->WithMetadataValue('Identity', 'Microsoft.NETCore.App')->WithMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}'))"
  25. LatestRuntimeFrameworkVersion="${MicrosoftNETCoreAppRuntimeVersion}">
  26. <!--
  27. Change the default shared framework and targeting pack version only when _not_ servicing. Avoid bumping
  28. version used in most projects. When servicing, projects can use $(TargetLatestRuntimePatch) to explicitly
  29. control whether assemblies build against default (false) or latest (true). When that property is not set, SDK
  30. uses default metadata in most cases but published apps e.g. tool projects (again, property not set) use latest.
  31. !temporary! Also check $(TargetLatestRuntimePatch) here because these metadata changes otherwise increase the
  32. minimum versions, making $(TargetLatestRuntimePatch) irrelevant. This helps to avoid problems with current
  33. `[assembly: AssemblyVersion(...)]` changes in dotnet/runtime assemblies and our MSBuild tasks.
  34. -->
  35. <DefaultRuntimeFrameworkVersion Condition=" '$(IsServicingBuild)' != 'true' AND
  36. '$(TargetLatestDotNetRuntime)' != 'false' ">${MicrosoftNETCoreAppRuntimeVersion}</DefaultRuntimeFrameworkVersion>
  37. <TargetingPackVersion Condition=" '$(IsServicingBuild)' != 'true' AND
  38. '$(TargetLatestDotNetRuntime)' != 'false' ">${MicrosoftNETCoreAppRefVersion}</TargetingPackVersion>
  39. </KnownFrameworkReference>
  40. <!-- Use the just-built ASP.NET Core shared framework if available except when building product code in servicing. -->
  41. <KnownFrameworkReference
  42. Update="@(KnownFrameworkReference->WithMetadataValue('Identity', 'Microsoft.AspNetCore.App')->WithMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}'))"
  43. Condition=" $(UpdateAspNetCoreKnownFramework) "
  44. LatestRuntimeFrameworkVersion="${MicrosoftAspNetCoreAppRuntimeVersion}"
  45. RuntimePackRuntimeIdentifiers="${SupportedRuntimeIdentifiers}">
  46. <DefaultRuntimeFrameworkVersion
  47. Condition=" '$(IsServicingBuild)' != 'true' ">${MicrosoftAspNetCoreAppRuntimeVersion}</DefaultRuntimeFrameworkVersion>
  48. <TargetingPackVersion
  49. Condition=" '$(IsServicingBuild)' != 'true' ">${MicrosoftAspNetCoreAppRefVersion}</TargetingPackVersion>
  50. </KnownFrameworkReference>
  51. </ItemGroup>
  52. <!-- Warn if the "just-built" ASP.NET Core shared framework does not exist. -->
  53. <Target Name="WarnAboutMissingSharedFramework"
  54. BeforeTargets="Restore;Build;Rebuild;RunTests;Test;VSTest;Pack"
  55. Condition=" $(UpdateAspNetCoreKnownFramework) ">
  56. <PropertyGroup>
  57. <!--
  58. Property (already normalized) from Arcade SDK's RepoLayout.props. This covers all projects using the
  59. Arcade SDK. Ignore $(LocalDotNetRoot) because that is set in root Directory.Build.props (where Arcade SDK
  60. is imported) and therefore doesn't cover additional projects.
  61. -->
  62. <_DotNetRoot Condition=" '$(DotNetRoot)' != '' ">$(DotNetRoot)</_DotNetRoot>
  63. <!--
  64. Environment variable from eng/common/tools.ps1 scripts. This covers tests and assets that do not use the
  65. Arcade SDK but are run from our build.* scripts.
  66. -->
  67. <_DotNetRoot Condition=" '$(_DotNetRoot)' == '' AND
  68. '$(DOTNET_INSTALL_DIR)' != '' ">$([MSBuild]::NormalizeDirectory('$(DOTNET_INSTALL_DIR)'))</_DotNetRoot>
  69. <!--
  70. Environment variable from root activate.* and Helix runtest.* scripts. This covers tests and assets on
  71. Helix agents and when run locally using 'msbuild' after activation.
  72. -->
  73. <_DotNetRoot Condition=" '$(_DotNetRoot)' == '' AND
  74. '$(DOTNET_ROOT)' != '' ">$([MSBuild]::NormalizeDirectory('$(DOTNET_ROOT)'))</_DotNetRoot>
  75. </PropertyGroup>
  76. <Error Text="Unable to determine dotnet root location." Condition=" '$(_DotNetRoot)' == '' " />
  77. <Error Text="Dotnet root location '$(_DotNetRoot)' does not exist." Condition=" !EXISTS('$(_DotNetRoot)') " />
  78. <Warning Text="Requested Microsoft.AspNetCore.App v${MicrosoftAspNetCoreAppRuntimeVersion} does not exist."
  79. Condition=" !EXISTS('$(_DotNetRoot)shared\Microsoft.AspNetCore.App\${MicrosoftAspNetCoreAppRuntimeVersion}') " />
  80. </Target>
  81. </Project>