Directory.build.targets 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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>
  7. <RxHasWpf>false</RxHasWpf>
  8. <RxHasWindowsForms>false</RxHasWindowsForms>
  9. <RxIsUap>false</RxIsUap>
  10. <RxHasWinRT>false</RxHasWinRT>
  11. </PropertyGroup>
  12. <PropertyGroup Condition="'$(TargetFramework)' == 'net472'">
  13. <DefineConstants>$(DefineConstants);HAS_WINFORMS;HAS_WPF;HAS_REMOTING;DESKTOPCLR;NO_NULLABLE_ATTRIBUTES</DefineConstants>
  14. <RxHasWpf>true</RxHasWpf>
  15. </PropertyGroup>
  16. <PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0.18362'">
  17. <DefineConstants>$(DefineConstants);HAS_WINRT;WINDOWS;IS_UAP;LEGACY_WINRT;NO_NULLABLE_ATTRIBUTES</DefineConstants>
  18. <RxIsUap>true</RxIsUap>
  19. <RxHasWinRT>true</RxHasWinRT>
  20. </PropertyGroup>
  21. <PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
  22. <DefineConstants>$(DefineConstants);NO_NULLABLE_ATTRIBUTES</DefineConstants>
  23. </PropertyGroup>
  24. <PropertyGroup Condition="$(TargetFramework.StartsWith('net8.0')) or $(TargetFramework.StartsWith('net9.0'))">
  25. <DefineConstants>$(DefineConstants);HAS_TRIMMABILITY_ATTRIBUTES</DefineConstants>
  26. </PropertyGroup>
  27. <PropertyGroup Condition="$(TargetFramework.StartsWith('net8.0-windows')) or $(TargetFramework.StartsWith('net9.0-windows'))">
  28. <!--
  29. Although Rx 7 removes WPF and Windows Forms support from the public API of System.Reactive, for now, we continue to
  30. set HAS_WPF, RxHasWpf, HAS_WINDOWS and RxHasWindowsForms here. System.Reactive builds the runtime assembly, which still contains
  31. the code for these frameworks, so; we've only removed that code from the public-facing ref assemblies. And the other
  32. projects that need to make conditional compilation decisions based on whether WPF is available all include WPF in their
  33. -windows targets. So these are the correct settings for compilation of projects that use them, even though System.Reactive itself
  34. does not publicly expose any WPF- or Windows Forms-related types or members.
  35. -->
  36. <DefineConstants>$(DefineConstants);HAS_WINFORMS;HAS_WPF;DESKTOPCLR;WINDOWS;CSWINRT</DefineConstants>
  37. <RxHasWpf>true</RxHasWpf>
  38. <RxHasWindowsForms>true</RxHasWindowsForms>
  39. </PropertyGroup>
  40. <PropertyGroup Condition="$(TargetFramework.StartsWith('net8.0-windows10')) or $(TargetFramework.StartsWith('net9.0-windows10'))">
  41. <DefineConstants>$(DefineConstants);HAS_WINRT;HAS_WINFORMS;HAS_WPF;DESKTOPCLR;WINDOWS;CSWINRT</DefineConstants>
  42. <RxHasWinRT>true</RxHasWinRT>
  43. </PropertyGroup>
  44. <ItemGroup Condition="('$(TargetFramework)' == 'net472' or '$(TargetFramework)' == 'uap10.0.18362' or '$(TargetFramework)' == 'netstandard2.0') and $(IsPackable)">
  45. <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
  46. </ItemGroup>
  47. <ItemGroup Condition="'$(TargetFramework)'=='uap10.0.18362'">
  48. <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform"
  49. Version="6.2.14" />
  50. </ItemGroup>
  51. <!-- Ensure correct resx file handling -->
  52. <ItemGroup>
  53. <!-- Runs code generator to produce strongly-typed resx wrapper type. -->
  54. <EmbeddedResource Update="**\*.resx">
  55. <Generator>ResXFileCodeGenerator</Generator>
  56. <CustomToolNamespace>System.Reactive</CustomToolNamespace>
  57. <LastGenOutput>$([System.IO.Path]::GetFileNameWithoutExtension('%(Filename)')).Designer.cs</LastGenOutput>
  58. </EmbeddedResource>
  59. <!-- Gets the correct grouping in VS -->
  60. <Compile Update="@(EmbeddedResource -> '%(LastGenOutput)')">
  61. <DependentUpon>$([System.IO.Path]::GetFileNameWithoutExtension('$([System.IO.Path]::GetFileNameWithoutExtension('%(Identity)'))')).resx</DependentUpon>
  62. <DesignTime>True</DesignTime>
  63. <AutoGen>True</AutoGen>
  64. </Compile>
  65. </ItemGroup>
  66. <PropertyGroup Condition="$(TargetFramework.StartsWith('net8.0-windows')) or $(TargetFramework.StartsWith('net9.0-windows'))">
  67. <!--
  68. 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.
  69. It's looking like it does this for any public type that implements IDisposable!
  70. It's possible that this is a bug in the SDK, but it's also possible that this will be resolved as by design.
  71. For the .NET 9.0 RC2 SDK at least, we need to opt out the CsWinRT AOT optimizer.
  72. 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,
  73. which isn't the case here, but we need to verify this.
  74. -->
  75. <CsWinRTAotOptimizerEnabled>false</CsWinRTAotOptimizerEnabled>
  76. </PropertyGroup>
  77. <Target Name="AddCommitHashToAssemblyAttributes" BeforeTargets="GetAssemblyAttributes">
  78. <ItemGroup>
  79. <AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition=" '$(SourceRevisionId)' != '' ">
  80. <_Parameter1>CommitHash</_Parameter1>
  81. <_Parameter2>$(SourceRevisionId)</_Parameter2>
  82. </AssemblyAttribute>
  83. </ItemGroup>
  84. </Target>
  85. <!-- Remove once coverlet supports this built-in -->
  86. <Target Name="CoverletGetPathMap"
  87. DependsOnTargets="InitializeSourceRootMappedPaths"
  88. Returns="@(_LocalTopLevelSourceRoot)"
  89. Condition="'$(DeterministicSourcePaths)' == 'true'">
  90. <ItemGroup>
  91. <_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/>
  92. </ItemGroup>
  93. </Target>
  94. </Project>