Directory.Build.targets 12 KB

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