Directory.Build.targets 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <Project>
  2. <PropertyGroup>
  3. <EnableAOTAnalyzer Condition=" '$(EnableAOTAnalyzer)' == '' ">$([MSBuild]::ValueOrDefault($(IsTrimmable),'false'))</EnableAOTAnalyzer>
  4. <!-- TODO: Remove when analyzer is enabled by default with AOT in SDK. See https://github.com/dotnet/sdk/issues/31284 -->
  5. <EnableSingleFileAnalyzer Condition=" '$(EnableSingleFileAnalyzer)' == '' ">$(EnableAOTAnalyzer)</EnableSingleFileAnalyzer>
  6. </PropertyGroup>
  7. <PropertyGroup>
  8. <!-- Ignore API doc requirements for test assets -->
  9. <NoWarn Condition="'$(IsTestAssetProject)' == 'true' or '$(IsSampleProject)' == 'true' or '$(IsBenchmarkProject)' == 'true' or
  10. '$(IsMicrobenchmarksProject)' == 'true'">$(NoWarn);CS1591</NoWarn>
  11. </PropertyGroup>
  12. <PropertyGroup Label="Resx settings">
  13. <GenerateResxSource Condition="'$(GenerateResxSource)' == ''">true</GenerateResxSource>
  14. <GenerateResxSourceEmitFormatMethods Condition="'$(GenerateResxSourceEmitFormatMethods)' == ''">true</GenerateResxSourceEmitFormatMethods>
  15. </PropertyGroup>
  16. <Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
  17. <!-- Properties which should be set after the project has been evaluated -->
  18. <PropertyGroup Label="Versioning settings">
  19. <!-- 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" -->
  20. <BrandingVersionSuffix>$(PreReleaseBrandingLabel) Build $(VersionSuffix)</BrandingVersionSuffix>
  21. <PackageBrandingVersion>$(VersionPrefix)</PackageBrandingVersion>
  22. <PackageBrandingVersion Condition=" '$(VersionSuffix)' != '' ">$(PackageBrandingVersion) $(BrandingVersionSuffix.Trim())</PackageBrandingVersion>
  23. <SiteExtensionVersion>$(VersionPrefix)</SiteExtensionVersion>
  24. <SiteExtensionVersion Condition=" '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix.Replace('.','-'))</SiteExtensionVersion>
  25. <PackageVersion Condition=" '$(PackageVersion)' == '' ">$(Version)</PackageVersion>
  26. <SharedFxVersion>$(PackageVersion)</SharedFxVersion>
  27. <SharedFxVersion Condition=" '$(StabilizePackageVersion)' == 'true' ">$(VersionPrefix)</SharedFxVersion>
  28. <SharedFxProductName>$(Product) $(SharedFxVersion) Shared Framework</SharedFxProductName>
  29. <TargetingPackVersion>$(SharedFxVersion)</TargetingPackVersion>
  30. <PackageVersion Condition=" '$(NoSemVer20)' == 'true' ">$(SiteExtensionVersion)</PackageVersion>
  31. </PropertyGroup>
  32. <PropertyGroup>
  33. <!-- 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. -->
  34. <SuppressDependenciesWhenPacking Condition="'$(SuppressDependenciesWhenPacking)' == '' AND '$(IsAnalyzersProject)' == 'true'">true</SuppressDependenciesWhenPacking>
  35. </PropertyGroup>
  36. <PropertyGroup Condition=" '$(MSBuildProjectExtension)' == '.csproj' ">
  37. <PackageId Condition=" '$(PackageId)' == '' ">$(AssemblyName)</PackageId>
  38. <IsPackable
  39. Condition="'$(IsPackable)' == '' AND ( $(IsTestProject) OR '$(IsTestAssetProject)' == 'true' OR
  40. '$(IsBenchmarkProject)' == 'true' OR '$(IsSampleProject)' == 'true' OR '$(IsMicrobenchmarksProject)' == 'true') ">false</IsPackable>
  41. </PropertyGroup>
  42. <Import Project="eng\Baseline.Designer.props" />
  43. <PropertyGroup Condition=" '$(IsPackable)' != 'false' AND '$(IsServicingBuild)' == 'true' ">
  44. <IsPackageInThisPatch Condition="'$(IsPackageInThisPatch)' == ''">true</IsPackageInThisPatch>
  45. <!-- Used to distinguish between packages building -->
  46. <IsPackableInNonServicingBuild>true</IsPackableInNonServicingBuild>
  47. <!-- Suppress creation of .nupkg for servicing builds of non-shipping projects. -->
  48. <IsPackable Condition=" '$(IsPackageInThisPatch)' != 'true' ">false</IsPackable>
  49. </PropertyGroup>
  50. <PropertyGroup>
  51. <!-- When OnlyPackPlatformSpecificPackages is set, only produce packages for projects which set RuntimeIdentifier. -->
  52. <!-- Keep this below where we set "IsPackageInThisPatch" -->
  53. <IsPackable Condition=" '$(OnlyPackPlatformSpecificPackages)' == 'true' AND '$(RuntimeIdentifier)' == '' ">false</IsPackable>
  54. </PropertyGroup>
  55. <PropertyGroup>
  56. <PackageVersionForPackageVersionInfo>$(PackageVersion)</PackageVersionForPackageVersionInfo>
  57. </PropertyGroup>
  58. <PropertyGroup Condition=" '$(IsPackageInThisPatch)' != 'true' AND '$(BaselinePackageVersion)' != '' AND '$(IsServicingBuild)' == 'true' ">
  59. <!-- This keeps assembly and package versions consistent across patches. If a package is not included in a patch, its version should stay at the baseline. -->
  60. <AssemblyVersion Condition="$(BaselinePackageVersion.Contains('-'))">$(BaselinePackageVersion.Substring(0, $(BaselinePackageVersion.IndexOf('-')))).0</AssemblyVersion>
  61. <AssemblyVersion Condition="! $(BaselinePackageVersion.Contains('-'))">$(BaselinePackageVersion).0</AssemblyVersion>
  62. <!--
  63. Ideally, we would also set the project version to match the baseline in case NuGet turns a ProjectReference into a nuspec depenendency, but
  64. NuGet does not currently handle conflicts between packages and projects which have the same package id/version.
  65. See https://github.com/NuGet/Home/issues/6795.
  66. Because we still use static analysis to scrape versions, only set this during static analysis, which can be detected by checking for both NoBuild and DesignTimeBuild.
  67. -->
  68. <Version Condition="'$(NoBuild)' == 'true' AND '$(DesignTimeBuild)' == 'true'">$(BaselinePackageVersion)</Version>
  69. <PackageVersion Condition="'$(NoBuild)' == 'true' AND '$(DesignTimeBuild)' == 'true'">$(BaselinePackageVersion)</PackageVersion>
  70. <!-- For servicing builds, we want to resolve baseline versions of project packages that aren't building, always -->
  71. <PackageVersionForPackageVersionInfo>$(BaselinePackageVersion)</PackageVersionForPackageVersionInfo>
  72. </PropertyGroup>
  73. <PropertyGroup>
  74. <!-- Implementation projects are the projects which produce nuget packages or shipping assemblies. -->
  75. <IsImplementationProject Condition=" '$(IsImplementationProject)' == '' AND
  76. '$(IsAnalyzersProject)' != 'true' AND
  77. '$(IsBenchmarkProject)' != 'true' AND
  78. '$(IsSampleProject)' != 'true' AND
  79. '$(IsSpecificationTestProject)' != 'true' AND
  80. '$(IsTestAssetProject)' != 'true' AND
  81. !$(IsTestProject) AND
  82. '$(IsMicrobenchmarksProject)' != 'true' ">true</IsImplementationProject>
  83. <!-- This determines whether a project is available as a <Reference> to other projects in this repo. -->
  84. <IsProjectReferenceProvider Condition=" '$(IsProjectReferenceProvider)' == '' AND
  85. ( '$(IsImplementationProject)' == 'true' OR '$(IsSpecificationTestProject)' == 'true' ) ">true</IsProjectReferenceProvider>
  86. <HasReferenceAssembly
  87. Condition=" '$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)' AND '$(IsAspNetCoreApp)' == 'true' ">true</HasReferenceAssembly>
  88. <HasReferenceAssembly Condition="'$(HasReferenceAssembly)' == ''">false</HasReferenceAssembly>
  89. <ProduceReferenceAssembly>$(HasReferenceAssembly)</ProduceReferenceAssembly>
  90. <!-- Duplicate setting from Microsoft.Common.CurrentVersion.targets because this is imported after that file. -->
  91. <TargetRefPath
  92. Condition=" '$(TargetRefPath)' == '' and $(ProduceReferenceAssembly) ">$([MSBuild]::NormalizePath($(TargetDir), 'ref', $(TargetFileName)))</TargetRefPath>
  93. <IsPackable Condition="'$(IsPackable)' == '' AND ('$(IsImplementationProject)' == 'true' OR '$(IsAnalyzersProject)' == 'true') ">true</IsPackable>
  94. <IsPackable Condition="'$(IsPackable)' == '' ">false</IsPackable>
  95. <BuildHelixPayload Condition="'$(BuildHelixPayload)' == '' AND $(IsTestProject) ">true</BuildHelixPayload>
  96. <SkipTests Condition="'$(SkipHelixReadyTests)' == 'true' AND '$(BuildHelixPayload)' == 'true'">true</SkipTests>
  97. </PropertyGroup>
  98. <PropertyGroup>
  99. <PackageThirdPartyNoticesFile Condition="'$(PackageThirdPartyNoticesFile)' == ''">$(RepoRoot)THIRD-PARTY-NOTICES.TXT</PackageThirdPartyNoticesFile>
  100. </PropertyGroup>
  101. <ItemGroup Condition="'$(IsPackable)' == 'true'">
  102. <None Include="$(PackageThirdPartyNoticesFile)" Pack="true" PackagePath="." />
  103. </ItemGroup>
  104. <!--
  105. If assembly is in shared framework and not net4*, assembly version should remain fixed for an entire
  106. major.minor release even in servicing.
  107. -->
  108. <PropertyGroup Condition=" '$(IsAspNetCoreApp)' == 'true' AND
  109. '$(Language)' == 'C#' AND
  110. '$(TargetFrameworkIdentifier)' != '.NETFramework' ">
  111. <AssemblyVersion>$(AspNetCoreMajorMinorVersion).0.0</AssemblyVersion>
  112. </PropertyGroup>
  113. <PropertyGroup>
  114. <!-- Do not update the Microsoft.AspNetCore.App KnownFrameworkReference item unless requested. -->
  115. <UpdateAspNetCoreKnownFramework>false</UpdateAspNetCoreKnownFramework>
  116. <UpdateAspNetCoreKnownFramework Condition=" '$(UseAspNetCoreSharedRuntime)' == 'true' AND
  117. '$(DoNotApplyWorkaroundsToMicrosoftAspNetCoreApp)' != 'true' ">true</UpdateAspNetCoreKnownFramework>
  118. </PropertyGroup>
  119. <ItemGroup>
  120. <KnownFrameworkReference Condition="'$(UseAspNetCoreSharedRuntime)' != 'true'" Remove="Microsoft.AspNetCore.App" />
  121. <KnownFrameworkReference Remove="Microsoft.WindowsDesktop.App" />
  122. </ItemGroup>
  123. <PropertyGroup Condition=" '$(CopySymbolsToArtifacts)' == 'true' AND '$(TargetFramework)' != '' ">
  124. <BuildDependsOn>$(BuildDependsOn);_CopySymbolsToArtifacts</BuildDependsOn>
  125. </PropertyGroup>
  126. <!-- Properties for Package Validation -->
  127. <PropertyGroup Condition="'$(ExcludeFromSourceBuild)' != 'true'">
  128. <EnablePackageValidation>true</EnablePackageValidation>
  129. <DisablePackageBaselineValidation Condition="'$(IsServicingBuild)' != 'true'">true</DisablePackageBaselineValidation>
  130. <GenerateCompatibilitySuppressionFile>true</GenerateCompatibilitySuppressionFile>
  131. </PropertyGroup>
  132. <Target Name="_CopySymbolsToArtifacts">
  133. <Copy SourceFiles="$([System.IO.Path]::ChangeExtension('$(TargetPath)', 'pdb'))"
  134. DestinationFolder="$(SymbolsOutputPath)$(TargetFramework)"
  135. OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
  136. Retries="$(CopyRetryCount)"
  137. RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
  138. SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" />
  139. </Target>
  140. <Import Project="eng\Workarounds.targets" />
  141. <Import Project="artifacts\bin\GenerateFiles\Directory.Build.targets" Condition=" '$(MSBuildProjectName)' != 'GenerateFiles' " />
  142. <Import Project="eng\targets\ResolveIisReferences.targets" Condition=" '$(MSBuildProjectExtension)' != '.vcxproj' " />
  143. <Import Project="eng\targets\Cpp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.vcxproj'" />
  144. <Import Project="eng\targets\CSharp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.csproj'" />
  145. <Import Project="eng\targets\FSharp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.fsproj'" />
  146. <Import Project="eng\targets\Wix.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.wixproj'" />
  147. <Import Project="eng\targets\Npm.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.npmproj'" />
  148. <Import Project="eng\targets\Java.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.javaproj'" />
  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>