Directory.Build.targets 12 KB

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