Skip to content

Commit

Permalink
Consolidate Directory.Build.targets
Browse files Browse the repository at this point in the history
  • Loading branch information
thohng committed May 12, 2024
1 parent 0c68c4a commit a3208c1
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 29 deletions.
4 changes: 4 additions & 0 deletions Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@

</PropertyGroup>

<PropertyGroup>
<DefineConstants Condition="'$(NET_6_0_LESS)' == true">NET_6_0_LESS</DefineConstants>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)Common.override.props" Condition="Exists('$(MSBuildThisFileDirectory)Common.override.props')" />

</Project>
95 changes: 67 additions & 28 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
</PropertyGroup>

<PropertyGroup Condition="'$(FrameworkVersion)' == ''">
<FrameworkVersion Condition="'$(NET_5_0_LESS)' == true">7.*</FrameworkVersion>
<FrameworkVersion Condition="'$(NET_3_1)' == true">3.1.*</FrameworkVersion>
<FrameworkVersion Condition="'$(NET_5_0)' == true">7.*</FrameworkVersion>
<FrameworkVersion Condition="'$(NET_6_0)' == true Or '$(NET_7_0)' == true Or '$(NET_8_0)' == true Or '$(NET_STD_2_X)' == true">8.*</FrameworkVersion>
<FrameworkVersion Condition="'$(NET_9_0_UP)' == true">9.*-*</FrameworkVersion>
<FrameworkVersion Condition="'$(FrameworkVersion)' == ''">$(LatestDevFrameworkVersion)</FrameworkVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(AspNetFrameworkVersion)' == ''">
<AspNetFrameworkVersion Condition="'$(NET_3_1)' == true">3.*</AspNetFrameworkVersion>
<AspNetFrameworkVersion Condition="'$(NET_3_1)' == true">3.1.*</AspNetFrameworkVersion>
<AspNetFrameworkVersion Condition="'$(NET_5_0)' == true">5.*</AspNetFrameworkVersion>
<AspNetFrameworkVersion Condition="'$(NET_6_0)' == true">6.*</AspNetFrameworkVersion>
<AspNetFrameworkVersion Condition="'$(NET_7_0)' == true">7.*</AspNetFrameworkVersion>
Expand All @@ -26,28 +27,34 @@
</PropertyGroup>

<PropertyGroup Condition="'$(EFCoreFrameworkVersion)' == ''">
<EFCoreFrameworkVersion Condition="'$(NET_5_0_LESS_OR_STD)' == true">5.*</EFCoreFrameworkVersion>
<EFCoreFrameworkVersion Condition="'$(NET_3_1_LESS_OR_STD)' == true">3.1.*</EFCoreFrameworkVersion>
<EFCoreFrameworkVersion Condition="'$(NET_5_0)' == true">5.*</EFCoreFrameworkVersion>
<EFCoreFrameworkVersion Condition="'$(NET_6_0)' == true Or '$(NET_7_0)' == true">7.*</EFCoreFrameworkVersion>
<EFCoreFrameworkVersion Condition="'$(NET_8_0)' == true">8.*</EFCoreFrameworkVersion>
<EFCoreFrameworkVersion Condition="'$(NET_9_0)' == true">9.*-*</EFCoreFrameworkVersion>
<EFCoreFrameworkVersion Condition="'$(EFCoreFrameworkVersion)' == ''">$(LatestDevFrameworkVersion)</EFCoreFrameworkVersion>
</PropertyGroup>

<PropertyGroup>
<NpgsqlVersion Condition="'$(NpgsqlVersion)' == '' And '$(NET_3_1_LESS_OR_STD)' == true">4.*</NpgsqlVersion>
<NpgsqlVersion Condition="'$(NpgsqlVersion)' == '' And '$(NET_9_0_UP)' == true">8.*</NpgsqlVersion>
<NpgsqlVersion Condition="'$(NpgsqlVersion)' == ''">$(EFCoreFrameworkVersion)</NpgsqlVersion>
<NuGetPackageVersion Condition="'$(NuGetPackageVersion)' == ''">6.*</NuGetPackageVersion>
<SystemTextJsonVersion Condition="'$(SystemTextJsonVersion)' == '' And '$(NET_5_0_LESS)' == true">8.*</SystemTextJsonVersion>
<SystemTextJsonVersion Condition="'$(SystemTextJsonVersion)' == ''">$(FrameworkVersion)</SystemTextJsonVersion>
<SwashbuckleVersion Condition="'$(SwashbuckleVersion)' == '' And '$(NET_5_0_LESS)' == true">6.3.*</SwashbuckleVersion>
<SwashbuckleVersion Condition="'$(SwashbuckleVersion)' == '' And '$(NET_6_0)' == true">6.4.*</SwashbuckleVersion>
<!-- Swashbuckle.AspNetCore@6.3.2 reference to Microsoft.Extensions.ApiDescription.Server@6.0.5 by mistake -->
<SwashbuckleVersion Condition="'$(SwashbuckleVersion)' == '' And '$(NET_5_0_LESS)' == true">6.3.1</SwashbuckleVersion>
<SwashbuckleVersion Condition="'$(SwashbuckleVersion)' == '' And '$(NET_6_0_UP)' == true">6.5.*</SwashbuckleVersion>
<SwashbuckleVersion Condition="'$(SwashbuckleVersion)' == ''">6.*</SwashbuckleVersion>
</PropertyGroup>

<ItemGroup>
<!--build related-->
<PackageReference Update="Bullseye" Version="4.*" />
<PackageReference Include="MinVer" Version="4.*" PrivateAssets="All" />
<PackageReference Update="Bullseye" Version="5.*" />
<PackageReference Include="MinVer" Version="5.*" PrivateAssets="All" />
<PackageReference Include="NetLah.AssemblyInfo.BuildTime.Target" Version="1.*" PrivateAssets="All" Condition="'$(ExcludeAssemblyBuildTime)' != true" />
<PackageReference Update="Microsoft.SourceLink.Gitea" Version="1.*" PrivateAssets="All" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.*" PrivateAssets="All" />
<PackageReference Update="Microsoft.SourceLink.Gitea" Version="8.*" PrivateAssets="All" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.*" PrivateAssets="All" />
<PackageReference Update="SimpleExec" Version="11.*" />

<!--the helpers -->
Expand Down Expand Up @@ -88,11 +95,11 @@
<PackageReference Update="Serilog.Sinks.Console" Version="5.*" />
<PackageReference Update="Serilog.Sinks.Debug" Version="2.*" />
<PackageReference Update="Serilog.Sinks.File" Version="5.*" />
<PackageReference Update="Serilog.Sinks.PeriodicBatching" Version="3.*" />
<PackageReference Update="Serilog.Sinks.Seq" Version="6.*" />
<PackageReference Update="Serilog.Sinks.PeriodicBatching" Version="4.*" />
<PackageReference Update="Serilog.Sinks.Seq" Version="7.*" />

<!--misc-->
<PackageReference Update="AutoMapper" Version="12.*" />
<PackageReference Update="AutoMapper" Version="13.*" />
<PackageReference Update="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.*" />
<PackageReference Update="BouncyCastle.NetCore" Version="1.9.*" />
<PackageReference Update="ClosedXML" Version="0.95.*" />
Expand All @@ -104,9 +111,12 @@
<PackageReference Update="ExcelDataReader" Version="3.*" />
<PackageReference Update="ExcelDataReader.DataSet" Version="3.*" />
<PackageReference Update="FileHelpers.Fluent.Fixed" Version="2.*" />
<PackageReference Update="Humanizer" Version="2.*" />
<PackageReference Update="Humanizer.Core" Version="2.*" />
<PackageReference Update="LazyCache.AspNetCore" Version="2.*" />
<PackageReference Update="LiteDB" Version="5.*" />
<PackageReference Update="Markdig" Version="0.*" />
<PackageReference Update="McMaster.Extensions.CommandLineUtils" Version="4.*" />
<PackageReference Update="MessagePack" Version="2.*" />
<PackageReference Update="MessagePack.Annotations" Version="2.*" />
<PackageReference Update="MiniProfiler.AspNetCore" Version="4.*" />
Expand Down Expand Up @@ -205,7 +215,7 @@
<PackageReference Update="Microsoft.Extensions.ObjectPool" Version="$(FrameworkVersion)" />
<PackageReference Update="Microsoft.Extensions.Primitives" Version="$(FrameworkVersion)" />
<PackageReference Update="Microsoft.Win32.SystemEvents" Version="$(FrameworkVersion)" />

<PackageReference Update="System.Collections.Immutable" Version="$(FrameworkVersion)" />
<PackageReference Update="System.Composition.AttributedModel" Version="$(FrameworkVersion)" />
<PackageReference Update="System.Composition.Convention" Version="$(FrameworkVersion)" />
Expand All @@ -223,6 +233,8 @@
<PackageReference Update="System.IO.Hashing" Version="$(FrameworkVersion)" />
<PackageReference Update="System.Memory.Data" Version="$(FrameworkVersion)" />
<PackageReference Update="System.Net.Http.Json" Version="$(FrameworkVersion)" />
<PackageReference Update="System.Reflection.Metadata" Version="$(FrameworkVersion)" />
<PackageReference Update="System.Reflection.Metadata" Version="1.*" Condition="'$(NET_3_1_LESS_OR_STD)' == true" />
<PackageReference Update="System.Reflection.MetadataLoadContext" Version="$(FrameworkVersion)" />
<PackageReference Update="System.Runtime.Caching" Version="$(FrameworkVersion)" />
<PackageReference Update="System.Security.Cryptography.Pkcs" Version="$(FrameworkVersion)" />
Expand All @@ -235,6 +247,10 @@
<PackageReference Update="System.Text.Json" Version="$(SystemTextJsonVersion)" />
<PackageReference Update="System.Windows.Extensions" Version="$(FrameworkVersion)" />

<!-- .NET 8.0 -->
<PackageReference Update="Microsoft.Bcl.TimeProvider" Version="$(FrameworkVersion)" Condition="'$(NET_8_0_UP)' == true" />
<PackageReference Update="Microsoft.Extensions.TimeProvider.Testing" Version="$(FrameworkVersion)" Condition="'$(NET_8_0_UP)' == true" />

<!--microsoft asp.net core-->
<PackageReference Update="Microsoft.Extensions.ApiDescription.Server" Version="$(AspNetFrameworkVersion)" />
<PackageReference Update="Microsoft.AspNetCore.Authentication.Certificate" Version="$(AspNetFrameworkVersion)" />
Expand Down Expand Up @@ -275,12 +291,12 @@
<PackageReference Update="Microsoft.SqlServer.Server" Version="1.*" />

<!-- EFCore.PG and Npgsql must same version https://github.com/npgsql/efcore.pg/issues/3011 -->
<PackageReference Update="Npgsql" Version="$(EFCoreFrameworkVersion)" />
<PackageReference Update="Npgsql" Version="$(NpgsqlVersion)" />
<PackageReference Update="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(EFCoreFrameworkVersion)" />
<PackageReference Update="EFCore.NamingConventions" Version="$(EFCoreFrameworkVersion)" />

<!--identityserver4 -->
<PackageReference Update="IdentityModel" Version="6.*" />
<PackageReference Update="IdentityModel" Version="7.*" />
<PackageReference Update="IdentityModel.AspNetCore.OAuth2Introspection" Version="6.*" />

<!--azure-->
Expand Down Expand Up @@ -341,15 +357,15 @@
<PackageReference Update="System.IdentityModel.Tokens.Jwt" Version="7.*" />

<!--nuget-->
<PackageReference Update="NuGet.Common" Version="6.*" />
<PackageReference Update="NuGet.Configuration" Version="6.*" />
<PackageReference Update="NuGet.DependencyResolver.Core" Version="6.*" />
<PackageReference Update="NuGet.Frameworks" Version="6.*" />
<PackageReference Update="NuGet.LibraryModel" Version="6.*" />
<PackageReference Update="NuGet.Packaging" Version="6.*" />
<PackageReference Update="NuGet.ProjectModel" Version="6.*" />
<PackageReference Update="NuGet.Protocol" Version="6.*" />
<PackageReference Update="NuGet.Versioning" Version="6.*" />
<PackageReference Update="NuGet.Common" Version="$(NuGetPackageVersion)" />
<PackageReference Update="NuGet.Configuration" Version="$(NuGetPackageVersion)" />
<PackageReference Update="NuGet.DependencyResolver.Core" Version="$(NuGetPackageVersion)" />
<PackageReference Update="NuGet.Frameworks" Version="$(NuGetPackageVersion)" />
<PackageReference Update="NuGet.LibraryModel" Version="$(NuGetPackageVersion)" />
<PackageReference Update="NuGet.Packaging" Version="$(NuGetPackageVersion)" />
<PackageReference Update="NuGet.ProjectModel" Version="$(NuGetPackageVersion)" />
<PackageReference Update="NuGet.Protocol" Version="$(NuGetPackageVersion)" />
<PackageReference Update="NuGet.Versioning" Version="$(NuGetPackageVersion)" />

<!--grpc-->
<PackageReference Update="Google.Protobuf" Version="3.21.*" />
Expand Down Expand Up @@ -390,20 +406,43 @@

</ItemGroup>

<ItemGroup Condition="'$(NET_5_0_LESS_OR_STD)' == true">
<ItemGroup Condition="'$(NET_3_1_LESS_OR_STD)' == true">
<PackageReference Update="Serilog" Version="3.0.*" />
<PackageReference Update="Serilog.AspNetCore" Version="6.*" />
<PackageReference Update="Serilog.Extensions.Hosting" Version="5.*" />
<PackageReference Update="Serilog.Extensions.Logging" Version="3.*" />
<PackageReference Update="Serilog.Formatting.Compact" Version="1.*" />
<PackageReference Update="Serilog.Settings.Configuration" Version="3.*" />
<PackageReference Update="Serilog.Sinks.Console" Version="4.*" />
<PackageReference Update="Serilog.Sinks.Debug" Version="2.*" />
<PackageReference Update="Serilog.Sinks.File" Version="5.*" />
<PackageReference Update="Serilog.Sinks.PeriodicBatching" Version="3.*" />
<PackageReference Update="Serilog.Sinks.Seq" Version="5.*" />
</ItemGroup>

<ItemGroup Condition="'$(NET_5_0)' == true">
<PackageReference Update="Serilog" Version="3.0.*" />
<PackageReference Update="Serilog.AspNetCore" Version="7.*" />
<PackageReference Update="Serilog.Extensions.Hosting" Version="7.*" />
<PackageReference Update="Serilog.Extensions.Logging" Version="7.*" />
<PackageReference Update="Serilog.Formatting.Compact" Version="1.*" />
<PackageReference Update="Serilog.Settings.Configuration" Version="7.*" />
<PackageReference Update="Serilog.Sinks.Console" Version="4.*" />
<PackageReference Update="Serilog.Sinks.Seq" Version="6.*" />

<PackageReference Update="Serilog.Sinks.Debug" Version="2.*" />
<PackageReference Update="Serilog.Sinks.File" Version="5.*" />
<PackageReference Update="Serilog.Sinks.PeriodicBatching" Version="3.*" />
<PackageReference Update="Serilog.Sinks.Seq" Version="5.*" />
</ItemGroup>

<ItemGroup Condition="'$(NET_5_0_LESS_OR_STD)' == true">
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.*" PrivateAssets="All" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)Directory.Build.override.targets" Condition="Exists('$(MSBuildThisFileDirectory)Directory.Build.override.targets')" />
<ItemGroup Condition="'$(NET_5_0_LESS)' == true">
<PackageReference Update="AutoMapper" Version="12.*" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)Directory.Build.override.targets" Condition="'$(PackageLibraryTargetFlag)' != true And Exists('$(MSBuildThisFileDirectory)Directory.Build.override.targets')" />

<Target Name="SetAssemblyVersion" AfterTargets="MinVer">
<PropertyGroup>
Expand Down
8 changes: 7 additions & 1 deletion src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove('Common.props', '$(MSBuildThisFileDirectory)'))" Condition="'$(ImportedCommonProps)' == ''" />

<Import Project="$(MSBuildThisFileDirectory)Directory.Build.initial.targets" Condition="Exists('$(MSBuildThisFileDirectory)Directory.Build.initial.targets')" />


<PropertyGroup Condition="'$(PackageLibraryTargetFlag)' == ''">
<PackageLibraryTargetFlag>true</PackageLibraryTargetFlag>
</PropertyGroup>

<PropertyGroup Condition="'$(LatestDevFrameworkVersion)' == ''">
<LatestDevFrameworkVersion>9.0.0-preview.1.*</LatestDevFrameworkVersion>
</PropertyGroup>
Expand All @@ -27,6 +31,8 @@
</PropertyGroup>

<PropertyGroup>
<NpgsqlVersion Condition="'$(NpgsqlVersion)' == '' And '$(NET_3_1_LESS_OR_STD)' == true">4.1.2</NpgsqlVersion>
<NpgsqlVersion Condition="'$(NpgsqlVersion)' == '' And '$(NET_9_0_UP)' == true">8.0.2</NpgsqlVersion>
<SystemTextJsonVersion Condition="'$(NET_5_0_LESS_OR_STD)' == true">5.0.0</SystemTextJsonVersion>
<SwashbuckleVersion Condition="'$(SwashbuckleVersion)' == ''">6.0.0</SwashbuckleVersion>
</PropertyGroup>
Expand Down

0 comments on commit a3208c1

Please sign in to comment.