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