Directory.Build.targets 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 Condition=" '$(IsPackable)' != 'false' AND '$(AspNetCorePatchVersion)' != '0' ">
  47. <IsPackageInThisPatch Condition="'$(IsPackageInThisPatch)' == ''">$(PackagesInPatch.Contains(' $(PackageId);'))</IsPackageInThisPatch>
  48. </PropertyGroup>
  49. <PropertyGroup Condition=" '$(IsPackable)' != 'false' AND '$(IsServicingBuild)' == 'true' ">
  50. <!-- Used to distinguish between packages building -->
  51. <IsPackableInNonServicingBuild>true</IsPackableInNonServicingBuild>
  52. <!-- Suppress creation of .nupkg for servicing builds. -->
  53. <IsPackable Condition=" '$(IsPackageInThisPatch)' != 'true' ">false</IsPackable>
  54. </PropertyGroup>
  55. <PropertyGroup Condition=" '$(IsPackageInThisPatch)' != 'true' AND '$(BaselinePackageVersion)' != '' AND '$(IsServicingBuild)' == 'true' ">
  56. <!-- 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. -->
  57. <AssemblyVersion Condition="$(BaselinePackageVersion.Contains('-'))">$(BaselinePackageVersion.Substring(0, $(BaselinePackageVersion.IndexOf('-')))).0</AssemblyVersion>
  58. <AssemblyVersion Condition="! $(BaselinePackageVersion.Contains('-'))">$(BaselinePackageVersion).0</AssemblyVersion>
  59. <!--
  60. Ideally, we would also set the project version to match the baseline in case NuGet turns a ProjectReference into a nuspec depenendency, but
  61. NuGet does not currently handle conflicts between packages and projects which have the same package id/version.
  62. See https://github.com/NuGet/Home/issues/6795.
  63. 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.
  64. -->
  65. <Version Condition="'$(NoBuild)' == 'true' AND '$(DesignTimeBuild)' == 'true'">$(BaselinePackageVersion)</Version>
  66. <PackageVersion Condition="'$(NoBuild)' == 'true' AND '$(DesignTimeBuild)' == 'true'">$(BaselinePackageVersion)</PackageVersion>
  67. </PropertyGroup>
  68. <PropertyGroup>
  69. <!-- Implementation projects are the projects which produce nuget packages or shipping assemblies. -->
  70. <IsImplementationProject Condition=" '$(IsImplementationProject)' == '' AND '$(IsAnalyzersProject)' != 'true' AND '$(IsTestAssetProject)' != 'true' AND '$(IsTestProject)' != 'true' AND '$(IsBenchmarkProject)' != 'true' AND '$(IsSampleProject)' != 'true' AND '$(IsReferenceAssemblyProject)' != 'true' ">true</IsImplementationProject>
  71. <!-- This determines whether a project is available as a <Reference> to other projects in this repo. -->
  72. <IsProjectReferenceProvider Condition=" '$(IsProjectReferenceProvider)' == '' AND '$(IsImplementationProject)' == 'true' AND '$(PackAsTool)' != 'true' ">true</IsProjectReferenceProvider>
  73. <HasReferenceAssembly Condition="'$(HasReferenceAssembly)' == '' AND '$(IsProjectReferenceProvider)' == 'true'">true</HasReferenceAssembly>
  74. <HasReferenceAssembly Condition="'$(HasReferenceAssembly)' == ''">false</HasReferenceAssembly>
  75. <IsPackable Condition="'$(IsPackable)' == '' AND ('$(IsImplementationProject)' == 'true' OR '$(IsAnalyzersProject)' == 'true') ">true</IsPackable>
  76. <IsPackable Condition="'$(IsPackable)' == '' ">false</IsPackable>
  77. <BuildHelixPayload Condition="'$(BuildHelixPayload)' == '' AND '$(IsTestProject)' == 'true'">true</BuildHelixPayload>
  78. </PropertyGroup>
  79. <ItemGroup Condition="'$(Language)' == 'C#' AND '$(IsReferenceAssemblyProject)' == 'true'">
  80. <Compile Include="$(SharedSourceRoot)ReferenceAssemblyInfo.cs" LinkBase="Properties" />
  81. </ItemGroup>
  82. <ItemGroup>
  83. <KnownFrameworkReference Update="Microsoft.NETCore.App">
  84. <!-- Always update the 'latest version', whether the repo is servicing or not. -->
  85. <LatestRuntimeFrameworkVersion Condition="'%(TargetFramework)' == '$(DefaultNetCoreTargetFramework)'">$(MicrosoftNETCoreAppRuntimeVersion)</LatestRuntimeFrameworkVersion>
  86. <!-- Only update the default runtime version for preview builds. -->
  87. <DefaultRuntimeFrameworkVersion Condition="'%(TargetFramework)' == '$(DefaultNetCoreTargetFramework)' and '$(IsServicingBuild)' != 'true'">$(MicrosoftNETCoreAppRuntimeVersion)</DefaultRuntimeFrameworkVersion>
  88. <!-- Only update the targeting pack version for preview builds. -->
  89. <TargetingPackVersion Condition="'%(TargetFramework)' == '$(DefaultNetCoreTargetFramework)' and '$(IsServicingBuild)' != 'true'">$(MicrosoftNETCoreAppRefPackageVersion)</TargetingPackVersion>
  90. </KnownFrameworkReference>
  91. <KnownFrameworkReference Condition="'$(UseAspNetCoreSharedRuntime)' != 'true'" Remove="Microsoft.AspNetCore.App" />
  92. <KnownFrameworkReference Remove="Microsoft.WindowsDesktop.App" />
  93. <KnownFrameworkReference Condition="'$(UseAspNetCoreSharedRuntime)' == 'true'" Update="Microsoft.AspNetCore.App">
  94. <LatestRuntimeFrameworkVersion>$(SharedFxVersion)</LatestRuntimeFrameworkVersion>
  95. <DefaultRuntimeFrameworkVersion Condition="'$(IsServicingBuild)' != 'true'">$(SharedFxVersion)</DefaultRuntimeFrameworkVersion>
  96. <TargetingPackVersion Condition="'$(IsServicingBuild)' != 'true'">$(SharedFxVersion)</TargetingPackVersion>
  97. </KnownFrameworkReference>
  98. <KnownFrameworkReference Update="NETStandard.Library">
  99. <TargetingPackVersion Condition="'%(TargetFramework)' == 'netstandard2.1' and '$(IsServicingBuild)' != 'true'">$(NETStandardLibraryRefPackageVersion)</TargetingPackVersion>
  100. </KnownFrameworkReference>
  101. <!-- Track compiler separately from Arcade.-->
  102. <PackageReference Include="Microsoft.Net.Compilers.Toolset"
  103. Version="$(MicrosoftNetCompilersToolsetPackageVersion)"
  104. PrivateAssets="all"
  105. IsImplicitlyDefined="true" />
  106. </ItemGroup>
  107. <PropertyGroup Condition=" '$(CopySymbolsToArtifacts)' == 'true' AND '$(TargetFramework)' != '' ">
  108. <BuildDependsOn>$(BuildDependsOn);_CopySymbolsToArtifacts</BuildDependsOn>
  109. </PropertyGroup>
  110. <Target Name="_CopySymbolsToArtifacts">
  111. <Copy SourceFiles="$([System.IO.Path]::ChangeExtension('$(TargetPath)', 'pdb'))"
  112. DestinationFolder="$(SymbolsOutputPath)$(TargetFramework)"
  113. OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
  114. Retries="$(CopyRetryCount)"
  115. RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
  116. SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" />
  117. </Target>
  118. <Import Project="eng\Workarounds.targets" />
  119. <Import Project="eng\targets\ResolveIisReferences.targets" Condition=" '$(MSBuildProjectExtension)' != '.vcxproj' " />
  120. <Import Project="eng\targets\Cpp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.vcxproj'" />
  121. <Import Project="eng\targets\CSharp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.csproj'" />
  122. <Import Project="eng\targets\FSharp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.fsproj'" />
  123. <Import Project="eng\targets\Wix.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.wixproj'" />
  124. <Import Project="eng\targets\Npm.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.npmproj'" />
  125. <Import Project="eng\targets\ReferenceAssembly.targets" Condition=" '$(HasReferenceAssembly)' == 'true' " />
  126. </Project>