Directory.Build.targets 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <Project>
  2. <PropertyGroup>
  3. <!-- When OnlyPackPlatformSpecificPackages is set, only produce packages for projects which set RuntimeIdentifier. -->
  4. <IsPackable Condition=" '$(OnlyPackPlatformSpecificPackages)' == 'true' AND '$(IsPackable)' != 'false' AND '$(RuntimeIdentifier)' == '' ">false</IsPackable>
  5. <!--
  6. By default, assemblies which are only in the Microsoft.AspNetCore.App shared framework are not available as NuGet packages.
  7. -->
  8. <IsPackable Condition="'$(IsAspNetCoreApp)' == 'true' AND '$(IsShippingPackage)' != 'true'">false</IsPackable>
  9. <!-- Only build assemblies in Microsoft.AspNetCore.App in source build -->
  10. <!-- Analyzer package are needed in source build for WebSDK -->
  11. <ExcludeFromSourceBuild Condition="'$(ExcludeFromSourceBuild)' == '' and '$(DotNetBuildFromSource)' == 'true' and '$(IsAspNetCoreApp)' != 'true' and '$(IsAnalyzersProject)' != 'true'">true</ExcludeFromSourceBuild>
  12. </PropertyGroup>
  13. <PropertyGroup Label="Resx settings">
  14. <GenerateResxSource Condition="$(GenerateResxSource) == ''">true</GenerateResxSource>
  15. <GenerateResxSourceEmitFormatMethods Condition="$(GenerateResxSourceEmitFormatMethods) == ''">true</GenerateResxSourceEmitFormatMethods>
  16. </PropertyGroup>
  17. <Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
  18. <!-- Properties which should be set after the project has been evaluated -->
  19. <PropertyGroup Label="Versioning settings">
  20. <!-- 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" -->
  21. <BrandingVersionSuffix>$(PreReleaseBrandingLabel) Build $(VersionSuffix)</BrandingVersionSuffix>
  22. <PackageBrandingVersion>$(VersionPrefix)</PackageBrandingVersion>
  23. <PackageBrandingVersion Condition=" '$(VersionSuffix)' != '' ">$(PackageBrandingVersion) $(BrandingVersionSuffix.Trim())</PackageBrandingVersion>
  24. <SiteExtensionSuffix>$(VersionPrefix)</SiteExtensionSuffix>
  25. <SiteExtensionPackageVersion Condition=" '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix.Replace('.','-'))</SiteExtensionPackageVersion>
  26. <PackageVersion Condition=" '$(PackageVersion)' == '' ">$(Version)</PackageVersion>
  27. <PackageVersion Condition=" '$(NoSemVer20)' == 'true' ">$(SiteExtensionPackageVersion)</PackageVersion>
  28. <SharedFxVersion>$(PackageVersion)</SharedFxVersion>
  29. <TargetingPackVersion>$(TargetingPackVersionPrefix)</TargetingPackVersion>
  30. <TargetingPackVersion Condition=" '$(VersionSuffix)' != '' ">$(TargetingPackVersionPrefix)-$(VersionSuffix)</TargetingPackVersion>
  31. <SharedFxProductName>$(Product) $(PackageVersion) Shared Framework</SharedFxProductName>
  32. </PropertyGroup>
  33. <PropertyGroup>
  34. <!-- 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. -->
  35. <SuppressDependenciesWhenPacking Condition="'$(SuppressDependenciesWhenPacking)' == '' AND '$(IsAnalyzersProject)' == 'true'">true</SuppressDependenciesWhenPacking>
  36. </PropertyGroup>
  37. <PropertyGroup Condition="'$(PackAsTool)' == 'true' AND '$(IsShippingPackage)' == 'true'">
  38. <!-- This is a requirement for Microsoft tool packages only. -->
  39. <PackAsToolShimRuntimeIdentifiers>win-x64;win-x86</PackAsToolShimRuntimeIdentifiers>
  40. </PropertyGroup>
  41. <PropertyGroup Condition=" '$(MSBuildProjectExtension)' == '.csproj' ">
  42. <PackageId Condition=" '$(PackageId)' == '' ">$(AssemblyName)</PackageId>
  43. <IsPackable Condition="'$(IsPackable)' == '' AND ( '$(IsTestProject)' == 'true' OR '$(IsTestAssetProject)' == 'true' OR '$(IsBenchmarkProject)' == 'true' OR '$(IsSampleProject)' == 'true' OR '$(IsReferenceAssemblyProject)' == 'true' ) ">false</IsPackable>
  44. </PropertyGroup>
  45. <Import Project="eng\Baseline.Designer.props" />
  46. <PropertyGroup
  47. Condition=" '$(IsPackable)' != 'false' AND '$(AspNetCorePatchVersion)' != '0' AND '$(DisableServicingFeatures)' != 'true' ">
  48. <IsPackageInThisPatch Condition="'$(IsPackageInThisPatch)' == ''">$(PackagesInPatch.Contains(' $(PackageId);'))</IsPackageInThisPatch>
  49. </PropertyGroup>
  50. <PropertyGroup Condition=" '$(IsPackable)' != 'false' AND '$(IsServicingBuild)' == 'true' ">
  51. <!-- Used to distinguish between packages building -->
  52. <IsPackableInNonServicingBuild>true</IsPackableInNonServicingBuild>
  53. <!-- Suppress creation of .nupkg for servicing builds. -->
  54. <IsPackable Condition=" '$(IsPackageInThisPatch)' != 'true' ">false</IsPackable>
  55. </PropertyGroup>
  56. <PropertyGroup Condition=" '$(IsPackageInThisPatch)' != 'true' AND '$(BaselinePackageVersion)' != '' AND '$(IsServicingBuild)' == 'true' ">
  57. <!-- 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. -->
  58. <AssemblyVersion Condition="$(BaselinePackageVersion.Contains('-'))">$(BaselinePackageVersion.Substring(0, $(BaselinePackageVersion.IndexOf('-')))).0</AssemblyVersion>
  59. <AssemblyVersion Condition="! $(BaselinePackageVersion.Contains('-'))">$(BaselinePackageVersion).0</AssemblyVersion>
  60. <!--
  61. Ideally, we would also set the project version to match the baseline in case NuGet turns a ProjectReference into a nuspec depenendency, but
  62. NuGet does not currently handle conflicts between packages and projects which have the same package id/version.
  63. See https://github.com/NuGet/Home/issues/6795.
  64. 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.
  65. -->
  66. <Version Condition="'$(NoBuild)' == 'true' AND '$(DesignTimeBuild)' == 'true'">$(BaselinePackageVersion)</Version>
  67. <PackageVersion Condition="'$(NoBuild)' == 'true' AND '$(DesignTimeBuild)' == 'true'">$(BaselinePackageVersion)</PackageVersion>
  68. </PropertyGroup>
  69. <PropertyGroup>
  70. <!-- Implementation projects are the projects which produce nuget packages or shipping assemblies. -->
  71. <IsImplementationProject Condition=" '$(IsImplementationProject)' == '' AND '$(IsAnalyzersProject)' != 'true' AND '$(IsTestAssetProject)' != 'true' AND '$(IsTestProject)' != 'true' AND '$(IsBenchmarkProject)' != 'true' AND '$(IsSampleProject)' != 'true' AND '$(IsReferenceAssemblyProject)' != 'true' ">true</IsImplementationProject>
  72. <!-- This determines whether a project is available as a <Reference> to other projects in this repo. -->
  73. <IsProjectReferenceProvider Condition=" '$(IsProjectReferenceProvider)' == '' AND '$(IsImplementationProject)' == 'true' AND '$(PackAsTool)' != 'true' ">true</IsProjectReferenceProvider>
  74. <HasReferenceAssembly Condition="'$(HasReferenceAssembly)' == '' AND '$(IsProjectReferenceProvider)' == 'true'">true</HasReferenceAssembly>
  75. <HasReferenceAssembly Condition="'$(HasReferenceAssembly)' == ''">false</HasReferenceAssembly>
  76. <IsPackable Condition="'$(IsPackable)' == '' AND ('$(IsImplementationProject)' == 'true' OR '$(IsAnalyzersProject)' == 'true') ">true</IsPackable>
  77. <IsPackable Condition="'$(IsPackable)' == '' ">false</IsPackable>
  78. <BuildHelixPayload Condition="'$(BuildHelixPayload)' == '' AND '$(IsTestProject)' == 'true'">true</BuildHelixPayload>
  79. </PropertyGroup>
  80. <ItemGroup Condition="'$(Language)' == 'C#' AND '$(IsReferenceAssemblyProject)' == 'true'">
  81. <Compile Include="$(SharedSourceRoot)ReferenceAssemblyInfo.cs" LinkBase="Properties" />
  82. </ItemGroup>
  83. <PropertyGroup Condition="'$(Language)' == 'C#'">
  84. <!-- Reference assemblies should always use Major.Minor.0.0 for assembly versions even during servicing. Only the package version should be updated. -->
  85. <!-- Pinning the implementation assemblies at Major.Minor.0.0 as we figure out compiling against ref assemblies. -->
  86. <AssemblyVersion>$(AspNetCoreMajorVersion).$(AspNetCoreMinorVersion).0.0</AssemblyVersion>
  87. </PropertyGroup>
  88. <ItemGroup>
  89. <KnownFrameworkReference Update="Microsoft.NETCore.App">
  90. <!-- Always update the 'latest version', whether the repo is servicing or not. -->
  91. <LatestRuntimeFrameworkVersion Condition="'%(TargetFramework)' == '$(DefaultNetCoreTargetFramework)'">$(MicrosoftNETCoreAppRuntimeVersion)</LatestRuntimeFrameworkVersion>
  92. <!-- Only update the default runtime version for preview builds. -->
  93. <DefaultRuntimeFrameworkVersion Condition="'%(TargetFramework)' == '$(DefaultNetCoreTargetFramework)' and '$(IsServicingBuild)' != 'true'">$(MicrosoftNETCoreAppRuntimeVersion)</DefaultRuntimeFrameworkVersion>
  94. <!-- Only update the targeting pack version for preview builds. -->
  95. <TargetingPackVersion Condition="'%(TargetFramework)' == '$(DefaultNetCoreTargetFramework)' and '$(IsServicingBuild)' != 'true'">$(MicrosoftNETCoreAppRefPackageVersion)</TargetingPackVersion>
  96. </KnownFrameworkReference>
  97. <KnownFrameworkReference Condition="'$(UseAspNetCoreSharedRuntime)' != 'true'" Remove="Microsoft.AspNetCore.App" />
  98. <KnownFrameworkReference Remove="Microsoft.WindowsDesktop.App" />
  99. <KnownFrameworkReference Condition="'$(UseAspNetCoreSharedRuntime)' == 'true'" Update="Microsoft.AspNetCore.App">
  100. <LatestRuntimeFrameworkVersion>$(SharedFxVersion)</LatestRuntimeFrameworkVersion>
  101. <DefaultRuntimeFrameworkVersion Condition="'$(IsServicingBuild)' != 'true'">$(SharedFxVersion)</DefaultRuntimeFrameworkVersion>
  102. <TargetingPackVersion Condition="'$(IsServicingBuild)' != 'true'">$(SharedFxVersion)</TargetingPackVersion>
  103. </KnownFrameworkReference>
  104. <KnownFrameworkReference Update="NETStandard.Library">
  105. <TargetingPackVersion Condition="'%(TargetFramework)' == 'netstandard2.1' and '$(IsServicingBuild)' != 'true'">$(NETStandardLibraryRefPackageVersion)</TargetingPackVersion>
  106. </KnownFrameworkReference>
  107. <!-- Track compiler separately from Arcade.-->
  108. <PackageReference Include="Microsoft.Net.Compilers.Toolset"
  109. Version="$(MicrosoftNetCompilersToolsetPackageVersion)"
  110. PrivateAssets="all"
  111. IsImplicitlyDefined="true" />
  112. </ItemGroup>
  113. <PropertyGroup Condition=" '$(CopySymbolsToArtifacts)' == 'true' AND '$(TargetFramework)' != '' ">
  114. <BuildDependsOn>$(BuildDependsOn);_CopySymbolsToArtifacts</BuildDependsOn>
  115. </PropertyGroup>
  116. <Target Name="_CopySymbolsToArtifacts">
  117. <Copy SourceFiles="$([System.IO.Path]::ChangeExtension('$(TargetPath)', 'pdb'))"
  118. DestinationFolder="$(SymbolsOutputPath)$(TargetFramework)"
  119. OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
  120. Retries="$(CopyRetryCount)"
  121. RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
  122. SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" />
  123. </Target>
  124. <Import Project="eng\Workarounds.targets" />
  125. <Import Project="eng\targets\ResolveIisReferences.targets" Condition=" '$(MSBuildProjectExtension)' != '.vcxproj' " />
  126. <Import Project="eng\targets\Cpp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.vcxproj'" />
  127. <Import Project="eng\targets\CSharp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.csproj'" />
  128. <Import Project="eng\targets\FSharp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.fsproj'" />
  129. <Import Project="eng\targets\Wix.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.wixproj'" />
  130. <Import Project="eng\targets\Npm.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.npmproj'" />
  131. <Import Project="eng\targets\ReferenceAssembly.targets" Condition=" '$(HasReferenceAssembly)' == 'true' " />
  132. </Project>