From df8a80537ac61ab74b42703d8ceb08687560697d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Sharma?= Date: Tue, 21 Jan 2020 20:51:04 -0800 Subject: [PATCH] Update to ASP.NET Core 3.1 (#446) Updates BaGet to ASP.NET Core 3.1. This is based off @MarkZither's work (see https://github.com/loic-sharma/BaGet/pull/443). Thank you for all the help @MarkZither! Part of https://github.com/loic-sharma/BaGet/issues/439 --- .azure/pipelines/ci-official.yml | 4 ++-- src/BaGet.Aws/BaGet.Aws.csproj | 2 +- src/BaGet.Azure/BaGet.Azure.csproj | 2 +- .../BaGet.Core.Server.csproj | 3 ++- src/BaGet.Core/BaGet.Core.csproj | 3 ++- src/BaGet.Core/Entities/AbstractContext.cs | 6 ++++-- .../Converters/StringArrayComparer.cs | 19 +++++++++++++++++++ .../BaGet.Database.MySql.csproj | 7 +++++-- .../BaGet.Database.PostgreSql.csproj | 9 ++++++--- .../BaGet.Database.SqlServer.csproj | 5 ++++- .../BaGet.Database.Sqlite.csproj | 5 ++++- src/BaGet.Gcp/BaGet.Gcp.csproj | 2 +- src/BaGet.Protocol/BaGet.Protocol.csproj | 2 +- src/BaGet/BaGet.csproj | 2 +- src/Directory.Build.props | 6 +++--- .../BaGet.Core.Tests/BaGet.Core.Tests.csproj | 4 ++-- .../BaGet.Protocol.Tests.csproj | 4 ++-- tests/BaGet.Tests/BaGet.Tests.csproj | 4 ++-- 18 files changed, 62 insertions(+), 27 deletions(-) create mode 100644 src/BaGet.Core/Entities/Converters/StringArrayComparer.cs diff --git a/.azure/pipelines/ci-official.yml b/.azure/pipelines/ci-official.yml index 7a998dfe..788dba04 100644 --- a/.azure/pipelines/ci-official.yml +++ b/.azure/pipelines/ci-official.yml @@ -40,9 +40,9 @@ jobs: vmImage: vs2017-win2016 steps: - task: UseDotNet@2 - displayName: 'Use .NET Core SDK 3.0.X' + displayName: 'Use .NET Core SDK 3.1.X' inputs: - version: 3.0.x + version: 3.1.x - task: Npm@1 displayName: Install frontend dependencies diff --git a/src/BaGet.Aws/BaGet.Aws.csproj b/src/BaGet.Aws/BaGet.Aws.csproj index e394489f..e2c8999b 100644 --- a/src/BaGet.Aws/BaGet.Aws.csproj +++ b/src/BaGet.Aws/BaGet.Aws.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netstandard2.0 NuGet;Amazon;Cloud The libraries to host BaGet on AWS. diff --git a/src/BaGet.Azure/BaGet.Azure.csproj b/src/BaGet.Azure/BaGet.Azure.csproj index 30060afa..7b567f6a 100644 --- a/src/BaGet.Azure/BaGet.Azure.csproj +++ b/src/BaGet.Azure/BaGet.Azure.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netstandard2.0 NuGet;Azure;Cloud The libraries to host BaGet on Azure. diff --git a/src/BaGet.Core.Server/BaGet.Core.Server.csproj b/src/BaGet.Core.Server/BaGet.Core.Server.csproj index c99a2bea..46e5ad4f 100644 --- a/src/BaGet.Core.Server/BaGet.Core.Server.csproj +++ b/src/BaGet.Core.Server/BaGet.Core.Server.csproj @@ -1,8 +1,9 @@ - netcoreapp3.0 + netcoreapp3.1 + NuGet BaGet's NuGet server implementation diff --git a/src/BaGet.Core/BaGet.Core.csproj b/src/BaGet.Core/BaGet.Core.csproj index 779a02ed..8c128749 100644 --- a/src/BaGet.Core/BaGet.Core.csproj +++ b/src/BaGet.Core/BaGet.Core.csproj @@ -1,8 +1,9 @@ - netcoreapp3.0 + netstandard2.0 + NuGet The core libraries that power BaGet. diff --git a/src/BaGet.Core/Entities/AbstractContext.cs b/src/BaGet.Core/Entities/AbstractContext.cs index f2a00b62..63f2618f 100644 --- a/src/BaGet.Core/Entities/AbstractContext.cs +++ b/src/BaGet.Core/Entities/AbstractContext.cs @@ -64,8 +64,9 @@ private void BuildPackageEntity(EntityTypeBuilder package) .HasMaxLength(MaxPackageVersionLength); package.Property(p => p.Authors) + .HasMaxLength(DefaultMaxStringLength) .HasConversion(StringArrayToJsonConverter.Instance) - .HasMaxLength(DefaultMaxStringLength); + .Metadata.SetValueComparer(StringArrayComparer.Instance); package.Property(p => p.IconUrl) .HasConversion(UriToStringConverter.Instance) @@ -84,8 +85,9 @@ private void BuildPackageEntity(EntityTypeBuilder package) .HasMaxLength(DefaultMaxStringLength); package.Property(p => p.Tags) + .HasMaxLength(DefaultMaxStringLength) .HasConversion(StringArrayToJsonConverter.Instance) - .HasMaxLength(DefaultMaxStringLength); + .Metadata.SetValueComparer(StringArrayComparer.Instance); package.Property(p => p.Description).HasMaxLength(DefaultMaxStringLength); package.Property(p => p.Language).HasMaxLength(MaxPackageLanguageLength); diff --git a/src/BaGet.Core/Entities/Converters/StringArrayComparer.cs b/src/BaGet.Core/Entities/Converters/StringArrayComparer.cs new file mode 100644 index 00000000..e76bcc62 --- /dev/null +++ b/src/BaGet.Core/Entities/Converters/StringArrayComparer.cs @@ -0,0 +1,19 @@ +using System; +using System.Linq; +using Microsoft.EntityFrameworkCore.ChangeTracking; + +namespace BaGet.Core +{ + public class StringArrayComparer : ValueComparer + { + public static readonly StringArrayComparer Instance = new StringArrayComparer(); + + public StringArrayComparer() + : base( + (c1, c2) => c1.SequenceEqual(c2), + c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())), + c => c.ToArray()) + { + } + } +} diff --git a/src/BaGet.Database.MySql/BaGet.Database.MySql.csproj b/src/BaGet.Database.MySql/BaGet.Database.MySql.csproj index ac39bb3a..adb58c0c 100644 --- a/src/BaGet.Database.MySql/BaGet.Database.MySql.csproj +++ b/src/BaGet.Database.MySql/BaGet.Database.MySql.csproj @@ -1,11 +1,14 @@ - netcoreapp3.0 + netstandard2.0 + + NuGet + The libraries to host BaGet on MySQL. - + diff --git a/src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj b/src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj index 856e4084..326cde78 100644 --- a/src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj +++ b/src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj @@ -1,11 +1,14 @@ - + - netcoreapp3.0 + netstandard2.0 + + NuGet + The libraries to host BaGet on PostgreSQL. - + diff --git a/src/BaGet.Database.SqlServer/BaGet.Database.SqlServer.csproj b/src/BaGet.Database.SqlServer/BaGet.Database.SqlServer.csproj index db2b3704..c6720e41 100644 --- a/src/BaGet.Database.SqlServer/BaGet.Database.SqlServer.csproj +++ b/src/BaGet.Database.SqlServer/BaGet.Database.SqlServer.csproj @@ -1,7 +1,10 @@ - netcoreapp3.0 + netstandard2.0 + + NuGet + The libraries to host BaGet on SQL Server. diff --git a/src/BaGet.Database.Sqlite/BaGet.Database.Sqlite.csproj b/src/BaGet.Database.Sqlite/BaGet.Database.Sqlite.csproj index 541d69c3..c7515daa 100644 --- a/src/BaGet.Database.Sqlite/BaGet.Database.Sqlite.csproj +++ b/src/BaGet.Database.Sqlite/BaGet.Database.Sqlite.csproj @@ -1,7 +1,10 @@ - netcoreapp3.0 + netstandard2.0 + + NuGet + The libraries to host BaGet on SQLite. diff --git a/src/BaGet.Gcp/BaGet.Gcp.csproj b/src/BaGet.Gcp/BaGet.Gcp.csproj index 24b7b2b8..3dc33ae6 100644 --- a/src/BaGet.Gcp/BaGet.Gcp.csproj +++ b/src/BaGet.Gcp/BaGet.Gcp.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netstandard2.0 NuGet;Google;Cloud The libraries to host BaGet on the Google Cloud Platform. diff --git a/src/BaGet.Protocol/BaGet.Protocol.csproj b/src/BaGet.Protocol/BaGet.Protocol.csproj index 7bdaaaa5..ff46124f 100644 --- a/src/BaGet.Protocol/BaGet.Protocol.csproj +++ b/src/BaGet.Protocol/BaGet.Protocol.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/BaGet/BaGet.csproj b/src/BaGet/BaGet.csproj index 74045017..4cd9b01a 100644 --- a/src/BaGet/BaGet.csproj +++ b/src/BaGet/BaGet.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netcoreapp3.1 ..\BaGet.UI\ $(DefaultItemExcludes);$(SpaRoot)node_modules\** diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 7c50b311..ec5bb265 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -27,9 +27,9 @@ - 3.0.2 - 3.0.2 - 3.0.2 + 3.1.1 + 3.1.1 + 3.1.1 5.0.0-rtm.5856 diff --git a/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj b/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj index 78820ba3..afe3c5b9 100644 --- a/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj +++ b/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.0 + netcoreapp3.1 diff --git a/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj b/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj index e633d889..28ef0c18 100644 --- a/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj +++ b/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.0 + netcoreapp3.1 diff --git a/tests/BaGet.Tests/BaGet.Tests.csproj b/tests/BaGet.Tests/BaGet.Tests.csproj index 4bc67f7c..e1fc2f5f 100644 --- a/tests/BaGet.Tests/BaGet.Tests.csproj +++ b/tests/BaGet.Tests/BaGet.Tests.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.0 + netcoreapp3.1