Directory.build.targets 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <Project>
  2. <!-- This props all need to be set in targets as they depend on the values set earlier -->
  3. <PropertyGroup>
  4. <Product>$(AssemblyName) ($(TargetFramework))</Product>
  5. </PropertyGroup>
  6. <PropertyGroup Condition="'$(TargetFramework)' == 'net472'">
  7. <DefineConstants>$(DefineConstants);HAS_WINFORMS;HAS_WPF;HAS_WINRT;HAS_DISPATCHER;HAS_REMOTING;DESKTOPCLR;NO_NULLABLE_ATTRIBUTES</DefineConstants>
  8. </PropertyGroup>
  9. <PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0.18362'">
  10. <DefineConstants>$(DefineConstants);HAS_WINRT;WINDOWS;HAS_OS_XAML;LEGACY_WINRT;NO_NULLABLE_ATTRIBUTES</DefineConstants>
  11. </PropertyGroup>
  12. <PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
  13. <DefineConstants>$(DefineConstants);HAS_WINRT;NO_NULLABLE_ATTRIBUTES</DefineConstants>
  14. </PropertyGroup>
  15. <PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0')) or $(TargetFramework.StartsWith('net7.0')) or $(TargetFramework.StartsWith('net8.0'))">
  16. <DefineConstants>$(DefineConstants);HAS_TRIMMABILITY_ATTRIBUTES</DefineConstants>
  17. </PropertyGroup>
  18. <PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-windows')) or $(TargetFramework.StartsWith('net8.0-windows')) or $(TargetFramework.StartsWith('net9.0-windows'))">
  19. <DefineConstants>$(DefineConstants);HAS_WINRT;HAS_WINFORMS;HAS_WPF;HAS_DISPATCHER;DESKTOPCLR;WINDOWS;CSWINRT</DefineConstants>
  20. </PropertyGroup>
  21. <ItemGroup Condition="('$(TargetFramework)' == 'net472' or '$(TargetFramework)' == 'uap10.0.18362' or '$(TargetFramework)' == 'netstandard2.0') and $(IsPackable)">
  22. <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
  23. </ItemGroup>
  24. <ItemGroup Condition="'$(TargetFramework)'=='uap10.0.18362'">
  25. <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform"
  26. Version="6.2.14" />
  27. </ItemGroup>
  28. <PropertyGroup Condition="$(TargetFramework.StartsWith('net6.0-windows')) or $(TargetFramework.StartsWith('net8.0-windows')) or $(TargetFramework.StartsWith('net9.0-windows'))">
  29. <!--
  30. In the 9.0.100-rc.2.24474.11 SDK, the build tools attempt to perform code generation for a whole load of our types to support WinRT interop.
  31. It's looking like it does this for any public type that implements IDisposable!
  32. It's possible that this is a bug in the SDK, but it's also possible that this will be resolved as by design.
  33. For the .NET 9.0 RC2 SDK at least, we need to opt out the CsWinRT AOT optimizer.
  34. We need to check whether this is definitely OK. I think this is only meant for types that are intended to be used from WinRT,
  35. which isn't the case here, but we need to verify this.
  36. -->
  37. <CsWinRTAotOptimizerEnabled>false</CsWinRTAotOptimizerEnabled>
  38. </PropertyGroup>
  39. <Target Name="AddCommitHashToAssemblyAttributes" BeforeTargets="GetAssemblyAttributes">
  40. <ItemGroup>
  41. <AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition=" '$(SourceRevisionId)' != '' ">
  42. <_Parameter1>CommitHash</_Parameter1>
  43. <_Parameter2>$(SourceRevisionId)</_Parameter2>
  44. </AssemblyAttribute>
  45. </ItemGroup>
  46. </Target>
  47. <!-- Remove once coverlet supports this built-in -->
  48. <Target Name="CoverletGetPathMap"
  49. DependsOnTargets="InitializeSourceRootMappedPaths"
  50. Returns="@(_LocalTopLevelSourceRoot)"
  51. Condition="'$(DeterministicSourcePaths)' == 'true'">
  52. <ItemGroup>
  53. <_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/>
  54. </ItemGroup>
  55. </Target>
  56. </Project>