Directory.Build.targets 12 KB

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