Directory.Build.targets 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. <!-- Disable IsTrimmable on non-DefaultNetCoreTargetFrameworks even if explicitly enabled or else we'll get NETSDK1195 and NETSDK1210 errors -->
  6. <IsTrimmable Condition="'$(TargetFramework)' != '$(DefaultNetCoreTargetFramework)'"></IsTrimmable>
  7. <EnableAOTAnalyzer Condition=" '$(EnableAOTAnalyzer)' == '' ">$([MSBuild]::ValueOrDefault($(IsTrimmable),'false'))</EnableAOTAnalyzer>
  8. <!-- TODO: Remove when analyzer is enabled by default with AOT in SDK. See https://github.com/dotnet/sdk/issues/31284 -->
  9. <EnableSingleFileAnalyzer Condition=" '$(EnableSingleFileAnalyzer)' == '' ">$(EnableAOTAnalyzer)</EnableSingleFileAnalyzer>
  10. </PropertyGroup>
  11. <PropertyGroup>
  12. <!-- Ignore API doc requirements for test assets -->
  13. <NoWarn Condition="'$(IsTestAssetProject)' == 'true' or '$(IsSampleProject)' == 'true' or '$(IsBenchmarkProject)' == 'true' or
  14. '$(IsMicrobenchmarksProject)' == 'true'">$(NoWarn);CS1591</NoWarn>
  15. </PropertyGroup>
  16. <PropertyGroup Label="Resx settings">
  17. <GenerateResxSource Condition="'$(GenerateResxSource)' == ''">true</GenerateResxSource>
  18. <GenerateResxSourceEmitFormatMethods Condition="'$(GenerateResxSourceEmitFormatMethods)' == ''">true</GenerateResxSourceEmitFormatMethods>
  19. </PropertyGroup>
  20. <Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
  21. <!-- Properties which should be set after the project has been evaluated -->
  22. <PropertyGroup Label="Versioning settings">
  23. <!-- The 'human friendly' version to display in installers. In pre-release builds, this might be "2.0.7 Preview 2 Build 12356". In final builds, it should be "2.0.7" -->
  24. <BrandingVersionSuffix>$(PreReleaseBrandingLabel) Build $(VersionSuffix)</BrandingVersionSuffix>
  25. <PackageBrandingVersion>$(VersionPrefix)</PackageBrandingVersion>
  26. <PackageBrandingVersion Condition=" '$(VersionSuffix)' != '' ">$(PackageBrandingVersion) $(BrandingVersionSuffix.Trim())</PackageBrandingVersion>
  27. <SiteExtensionVersion>$(VersionPrefix)</SiteExtensionVersion>
  28. <SiteExtensionVersion Condition=" '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix.Replace('.','-'))</SiteExtensionVersion>
  29. <PackageVersion Condition=" '$(PackageVersion)' == '' ">$(Version)</PackageVersion>
  30. <SharedFxVersion>$(PackageVersion)</SharedFxVersion>
  31. <SharedFxVersion Condition=" '$(StabilizePackageVersion)' == 'true' ">$(VersionPrefix)</SharedFxVersion>
  32. <SharedFxProductName>$(Product) $(SharedFxVersion) Shared Framework</SharedFxProductName>
  33. <TargetingPackVersion>$(SharedFxVersion)</TargetingPackVersion>
  34. <PackageVersion Condition=" '$(NoSemVer20)' == 'true' ">$(SiteExtensionVersion)</PackageVersion>
  35. </PropertyGroup>
  36. <PropertyGroup>
  37. <!-- Analyzers package are special. In general, they should not have dependencies in the nuspec. Analyzer assemblies are not meant to be used for compilation or runtime. -->
  38. <SuppressDependenciesWhenPacking Condition="'$(SuppressDependenciesWhenPacking)' == '' AND '$(IsAnalyzersProject)' == 'true'">true</SuppressDependenciesWhenPacking>
  39. </PropertyGroup>
  40. <PropertyGroup Condition=" '$(MSBuildProjectExtension)' == '.csproj' ">
  41. <PackageId Condition=" '$(PackageId)' == '' ">$(AssemblyName)</PackageId>
  42. <IsPackable
  43. Condition="'$(IsPackable)' == '' AND ( $(IsTestProject) OR '$(IsTestAssetProject)' == 'true' OR
  44. '$(IsBenchmarkProject)' == 'true' OR '$(IsSampleProject)' == 'true' OR '$(IsMicrobenchmarksProject)' == 'true') ">false</IsPackable>
  45. </PropertyGroup>
  46. <PropertyGroup Condition=" '$(IsPackable)' != 'false' AND '$(IsServicingBuild)' == 'true' ">
  47. <IsPackageInThisPatch Condition="'$(IsPackageInThisPatch)' == ''">true</IsPackageInThisPatch>
  48. <!-- Used to distinguish between packages building -->
  49. <IsPackableInNonServicingBuild>true</IsPackableInNonServicingBuild>
  50. <!-- Suppress creation of .nupkg for servicing builds of non-shipping projects. -->
  51. <IsPackable Condition=" '$(IsPackageInThisPatch)' != 'true' ">false</IsPackable>
  52. </PropertyGroup>
  53. <PropertyGroup>
  54. <!-- When OnlyPackPlatformSpecificPackages is set, only produce packages for projects which set RuntimeIdentifier. -->
  55. <!-- Keep this below where we set "IsPackageInThisPatch" -->
  56. <IsPackable Condition=" '$(OnlyPackPlatformSpecificPackages)' == 'true' AND '$(RuntimeIdentifier)' == '' ">false</IsPackable>
  57. </PropertyGroup>
  58. <PropertyGroup>
  59. <PackageVersionForPackageVersionInfo>$(PackageVersion)</PackageVersionForPackageVersionInfo>
  60. </PropertyGroup>
  61. <PropertyGroup>
  62. <!-- Implementation projects are the projects which produce nuget packages or shipping assemblies. -->
  63. <IsImplementationProject Condition=" '$(IsImplementationProject)' == '' AND
  64. '$(IsAnalyzersProject)' != 'true' AND
  65. '$(IsBenchmarkProject)' != 'true' AND
  66. '$(IsSampleProject)' != 'true' AND
  67. '$(IsSpecificationTestProject)' != 'true' AND
  68. '$(IsTestAssetProject)' != 'true' AND
  69. !$(IsTestProject) AND
  70. '$(IsMicrobenchmarksProject)' != 'true' ">true</IsImplementationProject>
  71. <!-- This determines whether a project is available as a <Reference> to other projects in this repo. -->
  72. <IsProjectReferenceProvider Condition=" '$(IsProjectReferenceProvider)' == '' AND
  73. ( '$(IsImplementationProject)' == 'true' OR '$(IsSpecificationTestProject)' == 'true' ) ">true</IsProjectReferenceProvider>
  74. <HasReferenceAssembly
  75. Condition=" '$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)' AND '$(IsAspNetCoreApp)' == 'true' ">true</HasReferenceAssembly>
  76. <HasReferenceAssembly Condition="'$(HasReferenceAssembly)' == ''">false</HasReferenceAssembly>
  77. <ProduceReferenceAssembly>$(HasReferenceAssembly)</ProduceReferenceAssembly>
  78. <!-- Duplicate setting from Microsoft.Common.CurrentVersion.targets because this is imported after that file. -->
  79. <TargetRefPath
  80. Condition=" '$(TargetRefPath)' == '' and $(ProduceReferenceAssembly) ">$([MSBuild]::NormalizePath($(TargetDir), 'ref', $(TargetFileName)))</TargetRefPath>
  81. <IsPackable Condition="'$(IsPackable)' == '' AND ('$(IsImplementationProject)' == 'true' OR '$(IsAnalyzersProject)' == 'true') ">true</IsPackable>
  82. <IsPackable Condition="'$(IsPackable)' == '' ">false</IsPackable>
  83. <BuildHelixPayload Condition="'$(BuildHelixPayload)' == '' AND $(IsTestProject) ">true</BuildHelixPayload>
  84. <SkipTests Condition="'$(SkipTests)' == '' AND '$(SkipHelixReadyTests)' == 'true' AND '$(BuildHelixPayload)' == 'true'">true</SkipTests>
  85. </PropertyGroup>
  86. <PropertyGroup>
  87. <PackageThirdPartyNoticesFile Condition="'$(PackageThirdPartyNoticesFile)' == ''">$(RepoRoot)THIRD-PARTY-NOTICES.TXT</PackageThirdPartyNoticesFile>
  88. </PropertyGroup>
  89. <ItemGroup Condition="'$(IsPackable)' == 'true'">
  90. <None Include="$(PackageThirdPartyNoticesFile)" Pack="true" PackagePath="." />
  91. </ItemGroup>
  92. <!--
  93. If assembly is in shared framework and not net4*, assembly version should remain fixed for an entire
  94. major.minor release even in servicing.
  95. -->
  96. <PropertyGroup Condition=" '$(IsAspNetCoreApp)' == 'true' AND
  97. '$(Language)' == 'C#' AND
  98. '$(TargetFrameworkIdentifier)' != '.NETFramework' ">
  99. <AssemblyVersion>$(AspNetCoreMajorMinorVersion).0.0</AssemblyVersion>
  100. </PropertyGroup>
  101. <PropertyGroup>
  102. <!-- Do not update the Microsoft.AspNetCore.App KnownFrameworkReference item unless requested. -->
  103. <UpdateAspNetCoreKnownFramework>false</UpdateAspNetCoreKnownFramework>
  104. <UpdateAspNetCoreKnownFramework Condition=" '$(UseAspNetCoreSharedRuntime)' == 'true' AND
  105. '$(DoNotApplyWorkaroundsToMicrosoftAspNetCoreApp)' != 'true' ">true</UpdateAspNetCoreKnownFramework>
  106. </PropertyGroup>
  107. <ItemGroup>
  108. <_RemovedAspNetKnownFrameworkReference Include="@(KnownFrameworkReference->WithMetadataValue('Identity', 'Microsoft.AspNetCore.App'))" />
  109. <KnownFrameworkReference Condition="'$(UseAspNetCoreSharedRuntime)' != 'true'" Remove="Microsoft.AspNetCore.App" />
  110. <KnownFrameworkReference Remove="Microsoft.WindowsDesktop.App" />
  111. </ItemGroup>
  112. <PropertyGroup Condition=" '$(CopySymbolsToArtifacts)' == 'true' AND '$(TargetFramework)' != '' ">
  113. <BuildDependsOn>$(BuildDependsOn);_CopySymbolsToArtifacts</BuildDependsOn>
  114. </PropertyGroup>
  115. <!-- Properties for Package Validation -->
  116. <PropertyGroup Condition="'$(ExcludeFromSourceOnlyBuild)' != 'true'">
  117. <EnablePackageValidation Condition="'$(EnablePackageValidation)' == ''">true</EnablePackageValidation>
  118. <DisablePackageBaselineValidation Condition="'$(IsServicingBuild)' != 'true'">true</DisablePackageBaselineValidation>
  119. <GenerateCompatibilitySuppressionFile>true</GenerateCompatibilitySuppressionFile>
  120. </PropertyGroup>
  121. <Target Name="_CopySymbolsToArtifacts">
  122. <Copy SourceFiles="$([System.IO.Path]::ChangeExtension('$(TargetPath)', 'pdb'))"
  123. DestinationFolder="$(SymbolsOutputPath)$(TargetFramework)"
  124. OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
  125. Retries="$(CopyRetryCount)"
  126. RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
  127. SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" />
  128. </Target>
  129. <!--
  130. Remove the implicit package reference for Microsoft.AspNetCore.App.Internal.Assets.
  131. Projects within the repo will consume framework assets by importing
  132. Microsoft.AspNetCore.App.Internal.Assets.targets directly
  133. -->
  134. <Target Name="_RemoveAspNetCoreAppInternalAssetsReference" AfterTargets="ProcessFrameworkReferences">
  135. <ItemGroup>
  136. <PackageReference Remove="Microsoft.AspNetCore.App.Internal.Assets" />
  137. </ItemGroup>
  138. </Target>
  139. <Import Project="eng\Workarounds.targets" />
  140. <Import Project="artifacts\bin\GenerateFiles\Directory.Build.targets" Condition=" '$(MSBuildProjectName)' != 'GenerateFiles' " />
  141. <Import Project="eng\targets\ResolveIisReferences.targets" Condition=" '$(MSBuildProjectExtension)' != '.vcxproj' " />
  142. <Import Project="eng\targets\Cpp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.vcxproj'" />
  143. <Import Project="eng\targets\CSharp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.csproj'" />
  144. <Import Project="eng\targets\FSharp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.fsproj'" />
  145. <Import Project="eng\targets\Wix.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.wixproj'" />
  146. <Import Project="eng\targets\Node.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.nodeproj'" />
  147. <Import Project="eng\targets\Java.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.javaproj'" />
  148. <Import Project="eng\targets\Sfx.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.sfxproj'" />
  149. <Import Project="eng\testing\linker\trimmingTests.targets" Condition="'$(IsPublishedAppTestProject)' == 'true'" />
  150. <Import Project="eng\targets\Helix.targets" Condition=" $(IsTestProject) " />
  151. <Import Project="eng\targets\FunctionalTestWithAssets.targets"
  152. Condition=" $(IsTestProject) AND $(ContainsFunctionalTestAssets) " />
  153. </Project>