diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e7a798b44..04d855201 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,6 +1,6 @@ -# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/dotnet/.devcontainer/base.Dockerfile +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/blob/main/containers/dotnet/.devcontainer/base.Dockerfile -# [Choice] .NET version: 5.0, 3.1, 2.1 -ARG VARIANT=3.1 +# [Choice] .NET version: 6.0, 5.0, 3.1, 2.1 +ARG VARIANT=6.0 FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 90c51c63c..9e928f035 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,14 +15,14 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore - - name: Test - run: dotnet test --no-build --verbosity normal + - uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cfd2806cc..afe09599c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.1.x + dotnet-version: 6.0.x - name: Test run: dotnet test --verbosity normal @@ -40,7 +40,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.1.x + dotnet-version: 6.0.x - name: Publish run: dotnet publish src/BaGet --configuration Release --output artifacts - name: Upload @@ -59,7 +59,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.1.x + dotnet-version: 6.0.x - name: Pack run: dotnet pack --configuration Release --output artifacts - name: Push diff --git a/Dockerfile b/Dockerfile index ee8ba3c5e..a6f0cd438 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY /src . RUN dotnet restore BaGet diff --git a/samples/BaGet.Protocol.Samples.Tests/BaGet.Protocol.Samples.Tests.csproj b/samples/BaGet.Protocol.Samples.Tests/BaGet.Protocol.Samples.Tests.csproj index 51c3b7967..1ad49fc9e 100644 --- a/samples/BaGet.Protocol.Samples.Tests/BaGet.Protocol.Samples.Tests.csproj +++ b/samples/BaGet.Protocol.Samples.Tests/BaGet.Protocol.Samples.Tests.csproj @@ -1,17 +1,16 @@ - netcoreapp3.1 - + net6.0 false IDE0007 - - + + - + all runtime; build; native; contentfiles; analyzers diff --git a/samples/BaGetWebApplication/BaGetWebApplication.csproj b/samples/BaGetWebApplication/BaGetWebApplication.csproj index 3123a668b..605ea3142 100644 --- a/samples/BaGetWebApplication/BaGetWebApplication.csproj +++ b/samples/BaGetWebApplication/BaGetWebApplication.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0 diff --git a/src/BaGet.Aliyun/BaGet.Aliyun.csproj b/src/BaGet.Aliyun/BaGet.Aliyun.csproj index ad7896fcc..302dc9096 100644 --- a/src/BaGet.Aliyun/BaGet.Aliyun.csproj +++ b/src/BaGet.Aliyun/BaGet.Aliyun.csproj @@ -2,11 +2,11 @@ NuGet;Alibaba;Cloud The libraries to host BaGet on Alibaba Cloud (Aliyun). - netstandard2.0 + net6.0 - + diff --git a/src/BaGet.Aws/BaGet.Aws.csproj b/src/BaGet.Aws/BaGet.Aws.csproj index 5094cd3d6..824f3f6af 100644 --- a/src/BaGet.Aws/BaGet.Aws.csproj +++ b/src/BaGet.Aws/BaGet.Aws.csproj @@ -1,15 +1,14 @@  - netstandard2.0 - + net6.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 7b567f6aa..c8e334b4c 100644 --- a/src/BaGet.Azure/BaGet.Azure.csproj +++ b/src/BaGet.Azure/BaGet.Azure.csproj @@ -1,8 +1,7 @@ - netstandard2.0 - + net6.0 NuGet;Azure;Cloud The libraries to host BaGet on Azure. diff --git a/src/BaGet.Core/BaGet.Core.csproj b/src/BaGet.Core/BaGet.Core.csproj index e88788429..335b0faf4 100644 --- a/src/BaGet.Core/BaGet.Core.csproj +++ b/src/BaGet.Core/BaGet.Core.csproj @@ -1,8 +1,7 @@ - netstandard2.0 - + net6.0 NuGet The core libraries that power BaGet. @@ -13,7 +12,7 @@ - + diff --git a/src/BaGet.Database.MySql/BaGet.Database.MySql.csproj b/src/BaGet.Database.MySql/BaGet.Database.MySql.csproj index adb58c0cf..0ca9c0cb2 100644 --- a/src/BaGet.Database.MySql/BaGet.Database.MySql.csproj +++ b/src/BaGet.Database.MySql/BaGet.Database.MySql.csproj @@ -1,14 +1,14 @@ - netstandard2.0 + net6.0 NuGet The libraries to host BaGet on MySQL. - + diff --git a/src/BaGet.Database.MySql/Migrations/20181212113156_Initial.cs b/src/BaGet.Database.MySql/Migrations/20181212113156_Initial.cs index 90101ee1a..8cccf9232 100644 --- a/src/BaGet.Database.MySql/Migrations/20181212113156_Initial.cs +++ b/src/BaGet.Database.MySql/Migrations/20181212113156_Initial.cs @@ -8,32 +8,50 @@ public partial class Initial : Migration { protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( name: "Packages", columns: table => new { - Key = table.Column(nullable: false) + Key = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Id = table.Column(maxLength: 128, nullable: false), - Authors = table.Column(maxLength: 4000, nullable: true), - Description = table.Column(maxLength: 4000, nullable: true), - Downloads = table.Column(nullable: false), - HasReadme = table.Column(nullable: false), - Language = table.Column(maxLength: 20, nullable: true), - Listed = table.Column(nullable: false), - MinClientVersion = table.Column(maxLength: 44, nullable: true), - Published = table.Column(nullable: false), - RequireLicenseAcceptance = table.Column(nullable: false), - Summary = table.Column(maxLength: 4000, nullable: true), - Title = table.Column(maxLength: 256, nullable: true), - IconUrl = table.Column(maxLength: 4000, nullable: true), - LicenseUrl = table.Column(maxLength: 4000, nullable: true), - ProjectUrl = table.Column(maxLength: 4000, nullable: true), - RepositoryUrl = table.Column(maxLength: 4000, nullable: true), - RepositoryType = table.Column(maxLength: 100, nullable: true), - Tags = table.Column(maxLength: 4000, nullable: true), - RowVersion = table.Column(rowVersion: true, nullable: true), - Version = table.Column(maxLength: 64, nullable: false) + Id = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Authors = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Downloads = table.Column(type: "bigint", nullable: false), + HasReadme = table.Column(type: "tinyint(1)", nullable: false), + Language = table.Column(type: "varchar(20)", maxLength: 20, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Listed = table.Column(type: "tinyint(1)", nullable: false), + MinClientVersion = table.Column(type: "varchar(44)", maxLength: 44, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Published = table.Column(type: "datetime(6)", nullable: false), + RequireLicenseAcceptance = table.Column(type: "tinyint(1)", nullable: false), + Summary = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Title = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IconUrl = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + LicenseUrl = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ProjectUrl = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + RepositoryUrl = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + RepositoryType = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Tags = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + RowVersion = table.Column(type: "timestamp(6)", rowVersion: true, nullable: true) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn), + Version = table.Column(type: "varchar(64)", maxLength: 64, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), }, constraints: table => { @@ -44,12 +62,15 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "PackageDependencies", columns: table => new { - Key = table.Column(nullable: false) + Key = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Id = table.Column(maxLength: 128, nullable: true), - VersionRange = table.Column(maxLength: 256, nullable: true), - TargetFramework = table.Column(maxLength: 256, nullable: true), - PackageKey = table.Column(nullable: false) + Id = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + VersionRange = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + TargetFramework = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + PackageKey = table.Column(type: "int", nullable: true) }, constraints: table => { diff --git a/src/BaGet.Database.MySql/Migrations/20190303071640_AddSearchDimensions.cs b/src/BaGet.Database.MySql/Migrations/20190303071640_AddSearchDimensions.cs index 02fb3c072..18bce5e5c 100644 --- a/src/BaGet.Database.MySql/Migrations/20190303071640_AddSearchDimensions.cs +++ b/src/BaGet.Database.MySql/Migrations/20190303071640_AddSearchDimensions.cs @@ -12,23 +12,17 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "FK_PackageDependencies_Packages_PackageKey", table: "PackageDependencies"); - migrationBuilder.AlterColumn( - name: "RowVersion", - table: "Packages", - rowVersion: true, - nullable: true, - oldClrType: typeof(DateTime), - oldNullable: true); - migrationBuilder.AddColumn( name: "IsPrerelease", table: "Packages", + type: "tinyint(1)", nullable: false, defaultValue: false); migrationBuilder.AddColumn( name: "SemVerLevel", table: "Packages", + type: "int", nullable: false, defaultValue: 0); @@ -42,11 +36,13 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "PackageTypes", columns: table => new { - Key = table.Column(nullable: false) + Key = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(maxLength: 512, nullable: true), - Version = table.Column(maxLength: 64, nullable: true), - PackageKey = table.Column(nullable: false) + Name = table.Column(type: "varchar(255)", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Version = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + PackageKey = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -63,10 +59,11 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "TargetFrameworks", columns: table => new { - Key = table.Column(nullable: false) + Key = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Moniker = table.Column(maxLength: 256, nullable: true), - PackageKey = table.Column(nullable: false) + Moniker = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + PackageKey = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -137,14 +134,6 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "SemVerLevel", table: "Packages"); - migrationBuilder.AlterColumn( - name: "RowVersion", - table: "Packages", - nullable: true, - oldClrType: typeof(DateTime), - oldRowVersion: true, - oldNullable: true); - migrationBuilder.AlterColumn( name: "PackageKey", table: "PackageDependencies", diff --git a/src/BaGet.Database.MySql/Migrations/20190914215810_AddOriginalVersionStringColumn.cs b/src/BaGet.Database.MySql/Migrations/20190914215810_AddOriginalVersionStringColumn.cs index df0217fe2..ea10e5177 100644 --- a/src/BaGet.Database.MySql/Migrations/20190914215810_AddOriginalVersionStringColumn.cs +++ b/src/BaGet.Database.MySql/Migrations/20190914215810_AddOriginalVersionStringColumn.cs @@ -7,17 +7,10 @@ public partial class AddOriginalVersionStringColumn : Migration { protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.AlterColumn( - name: "RowVersion", - table: "Packages", - rowVersion: true, - nullable: true, - oldClrType: typeof(DateTime), - oldNullable: true); - migrationBuilder.AddColumn( name: "OriginalVersion", table: "Packages", + type: "varchar(64)", maxLength: 64, nullable: true); } @@ -27,14 +20,6 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropColumn( name: "OriginalVersion", table: "Packages"); - - migrationBuilder.AlterColumn( - name: "RowVersion", - table: "Packages", - nullable: true, - oldClrType: typeof(DateTime), - oldRowVersion: true, - oldNullable: true); } } } diff --git a/src/BaGet.Database.MySql/Migrations/20200109085155_AddReleaseNotesStringColumn.cs b/src/BaGet.Database.MySql/Migrations/20200109085155_AddReleaseNotesStringColumn.cs index e098cdf86..b62e8a6a5 100644 --- a/src/BaGet.Database.MySql/Migrations/20200109085155_AddReleaseNotesStringColumn.cs +++ b/src/BaGet.Database.MySql/Migrations/20200109085155_AddReleaseNotesStringColumn.cs @@ -7,17 +7,10 @@ public partial class AddReleaseNotesStringColumn : Migration { protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.AlterColumn( - name: "RowVersion", - table: "Packages", - rowVersion: true, - nullable: true, - oldClrType: typeof(DateTime), - oldNullable: true); - migrationBuilder.AddColumn( name: "ReleaseNotes", table: "Packages", + type: "longtext", maxLength: 4000, nullable: true); } @@ -27,14 +20,6 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropColumn( name: "ReleaseNotes", table: "Packages"); - - migrationBuilder.AlterColumn( - name: "RowVersion", - table: "Packages", - nullable: true, - oldClrType: typeof(DateTime), - oldRowVersion: true, - oldNullable: true); } } } diff --git a/src/BaGet.Database.MySql/Migrations/20200210004047_AddHasEmbeddedIconColumn.cs b/src/BaGet.Database.MySql/Migrations/20200210004047_AddHasEmbeddedIconColumn.cs index d9b12c931..3c2a97ebb 100644 --- a/src/BaGet.Database.MySql/Migrations/20200210004047_AddHasEmbeddedIconColumn.cs +++ b/src/BaGet.Database.MySql/Migrations/20200210004047_AddHasEmbeddedIconColumn.cs @@ -8,18 +8,10 @@ public partial class AddHasEmbeddedIconColumn : Migration { protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.AlterColumn( - name: "RowVersion", - table: "Packages", - rowVersion: true, - nullable: true, - oldClrType: typeof(DateTime), - oldNullable: true) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); - migrationBuilder.AddColumn( name: "HasEmbeddedIcon", table: "Packages", + type: "tinyint(1)", nullable: false, defaultValue: false); } @@ -29,15 +21,6 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropColumn( name: "HasEmbeddedIcon", table: "Packages"); - - migrationBuilder.AlterColumn( - name: "RowVersion", - table: "Packages", - nullable: true, - oldClrType: typeof(DateTime), - oldRowVersion: true, - oldNullable: true) - .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); } } } diff --git a/src/BaGet.Database.MySql/Migrations/20210919191554_RemoveReleaseNotesMaxLength.cs b/src/BaGet.Database.MySql/Migrations/20210919191554_RemoveReleaseNotesMaxLength.cs index de331311c..e80122616 100644 --- a/src/BaGet.Database.MySql/Migrations/20210919191554_RemoveReleaseNotesMaxLength.cs +++ b/src/BaGet.Database.MySql/Migrations/20210919191554_RemoveReleaseNotesMaxLength.cs @@ -4,32 +4,15 @@ namespace BaGet.Database.MySql.Migrations { + // This was a migration without any sense, but I keep it cause of existing data public partial class RemoveReleaseNotesMaxLength : Migration { protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.AlterColumn( - name: "RowVersion", - table: "Packages", - rowVersion: true, - nullable: true, - oldClrType: typeof(DateTime), - oldType: "timestamp(6)", - oldNullable: true) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); } protected override void Down(MigrationBuilder migrationBuilder) { - migrationBuilder.AlterColumn( - name: "RowVersion", - table: "Packages", - type: "timestamp(6)", - nullable: true, - oldClrType: typeof(DateTime), - oldRowVersion: true, - oldNullable: true) - .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); } } } diff --git a/src/BaGet.Database.MySql/Migrations/20220123000903_AdjustTypesAccordingToLastProviderVersion.Designer.cs b/src/BaGet.Database.MySql/Migrations/20220123000903_AdjustTypesAccordingToLastProviderVersion.Designer.cs new file mode 100644 index 000000000..5f3256fa5 --- /dev/null +++ b/src/BaGet.Database.MySql/Migrations/20220123000903_AdjustTypesAccordingToLastProviderVersion.Designer.cs @@ -0,0 +1,248 @@ +// +using System; +using BaGet.Database.MySql; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BaGet.Database.MySql.Migrations +{ + [DbContext(typeof(MySqlContext))] + [Migration("20220123000903_AdjustTypesAccordingToLastProviderVersion")] + partial class AdjustTypesAccordingToLastProviderVersion + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("BaGet.Core.Package", b => + { + b.Property("Key") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Authors") + .HasColumnType("longtext"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("Downloads") + .HasColumnType("bigint"); + + b.Property("HasEmbeddedIcon") + .HasColumnType("tinyint(1)"); + + b.Property("HasReadme") + .HasColumnType("tinyint(1)"); + + b.Property("IconUrl") + .HasColumnType("longtext"); + + b.Property("Id") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsPrerelease") + .HasColumnType("tinyint(1)"); + + b.Property("Language") + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("LicenseUrl") + .HasColumnType("longtext"); + + b.Property("Listed") + .HasColumnType("tinyint(1)"); + + b.Property("MinClientVersion") + .HasMaxLength(44) + .HasColumnType("varchar(44)"); + + b.Property("NormalizedVersionString") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Version"); + + b.Property("OriginalVersionString") + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("OriginalVersion"); + + b.Property("ProjectUrl") + .HasColumnType("longtext"); + + b.Property("Published") + .HasColumnType("datetime(6)"); + + b.Property("ReleaseNotes") + .HasColumnType("longtext") + .HasColumnName("ReleaseNotes"); + + b.Property("RepositoryType") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("RepositoryUrl") + .HasColumnType("longtext"); + + b.Property("RequireLicenseAcceptance") + .HasColumnType("tinyint(1)"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("timestamp(6)"); + + b.Property("SemVerLevel") + .HasColumnType("int"); + + b.Property("Summary") + .HasColumnType("longtext"); + + b.Property("Tags") + .HasColumnType("longtext"); + + b.Property("Title") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Key"); + + b.HasIndex("Id"); + + b.HasIndex("Id", "NormalizedVersionString") + .IsUnique(); + + b.ToTable("Packages"); + }); + + modelBuilder.Entity("BaGet.Core.PackageDependency", b => + { + b.Property("Key") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Id") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("PackageKey") + .HasColumnType("int"); + + b.Property("TargetFramework") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("VersionRange") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Key"); + + b.HasIndex("Id"); + + b.HasIndex("PackageKey"); + + b.ToTable("PackageDependencies"); + }); + + modelBuilder.Entity("BaGet.Core.PackageType", b => + { + b.Property("Key") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("varchar(255)"); + + b.Property("PackageKey") + .HasColumnType("int"); + + b.Property("Version") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Key"); + + b.HasIndex("Name"); + + b.HasIndex("PackageKey"); + + b.ToTable("PackageTypes"); + }); + + modelBuilder.Entity("BaGet.Core.TargetFramework", b => + { + b.Property("Key") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Moniker") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PackageKey") + .HasColumnType("int"); + + b.HasKey("Key"); + + b.HasIndex("Moniker"); + + b.HasIndex("PackageKey"); + + b.ToTable("TargetFrameworks"); + }); + + modelBuilder.Entity("BaGet.Core.PackageDependency", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("Dependencies") + .HasForeignKey("PackageKey"); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("BaGet.Core.PackageType", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("PackageTypes") + .HasForeignKey("PackageKey") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("BaGet.Core.TargetFramework", b => + { + b.HasOne("BaGet.Core.Package", "Package") + .WithMany("TargetFrameworks") + .HasForeignKey("PackageKey") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("BaGet.Core.Package", b => + { + b.Navigation("Dependencies"); + + b.Navigation("PackageTypes"); + + b.Navigation("TargetFrameworks"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/BaGet.Database.MySql/Migrations/20220123000903_AdjustTypesAccordingToLastProviderVersion.cs b/src/BaGet.Database.MySql/Migrations/20220123000903_AdjustTypesAccordingToLastProviderVersion.cs new file mode 100644 index 000000000..81b8fc5a7 --- /dev/null +++ b/src/BaGet.Database.MySql/Migrations/20220123000903_AdjustTypesAccordingToLastProviderVersion.cs @@ -0,0 +1,268 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BaGet.Database.MySql.Migrations +{ + public partial class AdjustTypesAccordingToLastProviderVersion : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Name", + table: "PackageTypes", + type: "varchar(255)", + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(512)", + oldMaxLength: 512, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Tags", + table: "Packages", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext CHARACTER SET utf8mb4", + oldMaxLength: 4000, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Summary", + table: "Packages", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext CHARACTER SET utf8mb4", + oldMaxLength: 4000, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "RowVersion", + table: "Packages", + type: "timestamp(6)", + rowVersion: true, + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp(6)", + oldRowVersion: true, + oldNullable: true) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + name: "RepositoryUrl", + table: "Packages", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext CHARACTER SET utf8mb4", + oldMaxLength: 4000, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "ProjectUrl", + table: "Packages", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext CHARACTER SET utf8mb4", + oldMaxLength: 4000, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "LicenseUrl", + table: "Packages", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext CHARACTER SET utf8mb4", + oldMaxLength: 4000, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "IconUrl", + table: "Packages", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext CHARACTER SET utf8mb4", + oldMaxLength: 4000, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "Packages", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext CHARACTER SET utf8mb4", + oldMaxLength: 4000, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Authors", + table: "Packages", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext CHARACTER SET utf8mb4", + oldMaxLength: 4000, + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Name", + table: "PackageTypes", + type: "varchar(512)", + maxLength: 512, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Tags", + table: "Packages", + type: "longtext CHARACTER SET utf8mb4", + maxLength: 4000, + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Summary", + table: "Packages", + type: "longtext CHARACTER SET utf8mb4", + maxLength: 4000, + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "RowVersion", + table: "Packages", + type: "timestamp(6)", + rowVersion: true, + nullable: true, + oldClrType: typeof(DateTime), + oldType: "timestamp(6)", + oldRowVersion: true, + oldNullable: true) + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn); + + migrationBuilder.AlterColumn( + name: "RepositoryUrl", + table: "Packages", + type: "longtext CHARACTER SET utf8mb4", + maxLength: 4000, + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "ReleaseNotes", + table: "Packages", + type: "longtext CHARACTER SET utf8mb4", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "ProjectUrl", + table: "Packages", + type: "longtext CHARACTER SET utf8mb4", + maxLength: 4000, + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "LicenseUrl", + table: "Packages", + type: "longtext CHARACTER SET utf8mb4", + maxLength: 4000, + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "IconUrl", + table: "Packages", + type: "longtext CHARACTER SET utf8mb4", + maxLength: 4000, + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "Packages", + type: "longtext CHARACTER SET utf8mb4", + maxLength: 4000, + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Authors", + table: "Packages", + type: "longtext CHARACTER SET utf8mb4", + maxLength: 4000, + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + } + } +} diff --git a/src/BaGet.Database.MySql/Migrations/MySqlContextModelSnapshot.cs b/src/BaGet.Database.MySql/Migrations/MySqlContextModelSnapshot.cs index d9a6e93c8..d5d035270 100644 --- a/src/BaGet.Database.MySql/Migrations/MySqlContextModelSnapshot.cs +++ b/src/BaGet.Database.MySql/Migrations/MySqlContextModelSnapshot.cs @@ -5,6 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +#nullable disable + namespace BaGet.Database.MySql.Migrations { [DbContext(typeof(MySqlContext))] @@ -14,7 +16,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.1.18") + .HasAnnotation("ProductVersion", "6.0.1") .HasAnnotation("Relational:MaxIdentifierLength", 64); modelBuilder.Entity("BaGet.Core.Package", b => @@ -24,12 +26,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("int"); b.Property("Authors") - .HasColumnType("longtext CHARACTER SET utf8mb4") - .HasMaxLength(4000); + .HasColumnType("longtext"); b.Property("Description") - .HasColumnType("longtext CHARACTER SET utf8mb4") - .HasMaxLength(4000); + .HasColumnType("longtext"); b.Property("Downloads") .HasColumnType("bigint"); @@ -41,61 +41,57 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("tinyint(1)"); b.Property("IconUrl") - .HasColumnType("longtext CHARACTER SET utf8mb4") - .HasMaxLength(4000); + .HasColumnType("longtext"); b.Property("Id") .IsRequired() - .HasColumnType("varchar(128) CHARACTER SET utf8mb4") - .HasMaxLength(128); + .HasMaxLength(128) + .HasColumnType("varchar(128)"); b.Property("IsPrerelease") .HasColumnType("tinyint(1)"); b.Property("Language") - .HasColumnType("varchar(20) CHARACTER SET utf8mb4") - .HasMaxLength(20); + .HasMaxLength(20) + .HasColumnType("varchar(20)"); b.Property("LicenseUrl") - .HasColumnType("longtext CHARACTER SET utf8mb4") - .HasMaxLength(4000); + .HasColumnType("longtext"); b.Property("Listed") .HasColumnType("tinyint(1)"); b.Property("MinClientVersion") - .HasColumnType("varchar(44) CHARACTER SET utf8mb4") - .HasMaxLength(44); + .HasMaxLength(44) + .HasColumnType("varchar(44)"); b.Property("NormalizedVersionString") .IsRequired() - .HasColumnName("Version") - .HasColumnType("varchar(64) CHARACTER SET utf8mb4") - .HasMaxLength(64); + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("Version"); b.Property("OriginalVersionString") - .HasColumnName("OriginalVersion") - .HasColumnType("varchar(64) CHARACTER SET utf8mb4") - .HasMaxLength(64); + .HasMaxLength(64) + .HasColumnType("varchar(64)") + .HasColumnName("OriginalVersion"); b.Property("ProjectUrl") - .HasColumnType("longtext CHARACTER SET utf8mb4") - .HasMaxLength(4000); + .HasColumnType("longtext"); b.Property("Published") .HasColumnType("datetime(6)"); b.Property("ReleaseNotes") - .HasColumnName("ReleaseNotes") - .HasColumnType("longtext CHARACTER SET utf8mb4"); + .HasColumnType("longtext") + .HasColumnName("ReleaseNotes"); b.Property("RepositoryType") - .HasColumnType("varchar(100) CHARACTER SET utf8mb4") - .HasMaxLength(100); + .HasMaxLength(100) + .HasColumnType("varchar(100)"); b.Property("RepositoryUrl") - .HasColumnType("longtext CHARACTER SET utf8mb4") - .HasMaxLength(4000); + .HasColumnType("longtext"); b.Property("RequireLicenseAcceptance") .HasColumnType("tinyint(1)"); @@ -109,16 +105,14 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("int"); b.Property("Summary") - .HasColumnType("longtext CHARACTER SET utf8mb4") - .HasMaxLength(4000); + .HasColumnType("longtext"); b.Property("Tags") - .HasColumnType("longtext CHARACTER SET utf8mb4") - .HasMaxLength(4000); + .HasColumnType("longtext"); b.Property("Title") - .HasColumnType("varchar(256) CHARACTER SET utf8mb4") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("varchar(256)"); b.HasKey("Key"); @@ -137,19 +131,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("int"); b.Property("Id") - .HasColumnType("varchar(128) CHARACTER SET utf8mb4") - .HasMaxLength(128); + .HasMaxLength(128) + .HasColumnType("varchar(128)"); b.Property("PackageKey") .HasColumnType("int"); b.Property("TargetFramework") - .HasColumnType("varchar(256) CHARACTER SET utf8mb4") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("varchar(256)"); b.Property("VersionRange") - .HasColumnType("varchar(256) CHARACTER SET utf8mb4") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("varchar(256)"); b.HasKey("Key"); @@ -167,15 +161,14 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("int"); b.Property("Name") - .HasColumnType("varchar(512) CHARACTER SET utf8mb4") - .HasMaxLength(512); + .HasColumnType("varchar(255)"); b.Property("PackageKey") .HasColumnType("int"); b.Property("Version") - .HasColumnType("varchar(64) CHARACTER SET utf8mb4") - .HasMaxLength(64); + .HasMaxLength(64) + .HasColumnType("varchar(64)"); b.HasKey("Key"); @@ -193,8 +186,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("int"); b.Property("Moniker") - .HasColumnType("varchar(256) CHARACTER SET utf8mb4") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("varchar(256)"); b.Property("PackageKey") .HasColumnType("int"); @@ -213,6 +206,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasOne("BaGet.Core.Package", "Package") .WithMany("Dependencies") .HasForeignKey("PackageKey"); + + b.Navigation("Package"); }); modelBuilder.Entity("BaGet.Core.PackageType", b => @@ -222,6 +217,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasForeignKey("PackageKey") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Package"); }); modelBuilder.Entity("BaGet.Core.TargetFramework", b => @@ -231,6 +228,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasForeignKey("PackageKey") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("BaGet.Core.Package", b => + { + b.Navigation("Dependencies"); + + b.Navigation("PackageTypes"); + + b.Navigation("TargetFrameworks"); }); #pragma warning restore 612, 618 } diff --git a/src/BaGet.Database.MySql/MySqlApplicationExtensions.cs b/src/BaGet.Database.MySql/MySqlApplicationExtensions.cs index 2156d90c3..502859a2d 100644 --- a/src/BaGet.Database.MySql/MySqlApplicationExtensions.cs +++ b/src/BaGet.Database.MySql/MySqlApplicationExtensions.cs @@ -15,7 +15,7 @@ public static BaGetApplication AddMySqlDatabase(this BaGetApplication app) { var databaseOptions = provider.GetRequiredService>(); - options.UseMySql(databaseOptions.Value.ConnectionString); + options.UseMySql(databaseOptions.Value.ConnectionString, ServerVersion.AutoDetect(databaseOptions.Value.ConnectionString)); }); return app; diff --git a/src/BaGet.Database.MySql/MySqlContext.cs b/src/BaGet.Database.MySql/MySqlContext.cs index 49bbb65fb..70961d4f5 100644 --- a/src/BaGet.Database.MySql/MySqlContext.cs +++ b/src/BaGet.Database.MySql/MySqlContext.cs @@ -1,30 +1,59 @@ +using System; +using System.Linq; using BaGet.Core; using Microsoft.EntityFrameworkCore; -using MySql.Data.MySqlClient; +using MySqlConnector; namespace BaGet.Database.MySql { public class MySqlContext : AbstractContext { + /// + /// Max string length for mapping to varchar(N) + /// It string length will be greater than that value, it would be mapped to a longtext + /// + private const int MaxAllowedVarcharLength = 256; + /// /// The MySQL Server error code for when a unique constraint is violated. /// private const int UniqueConstraintViolationErrorCode = 1062; - public MySqlContext(DbContextOptions options) : base(options) + public MySqlContext(DbContextOptions options) + : base(options) { } - public override bool IsUniqueConstraintViolationException(DbUpdateException exception) - { - return exception.InnerException is MySqlException mysqlException && - mysqlException.Number == UniqueConstraintViolationErrorCode; - } - /// /// MySQL does not support LIMIT clauses in subqueries for certain subquery operators. /// See: https://dev.mysql.com/doc/refman/8.0/en/subquery-restrictions.html /// public override bool SupportsLimitInSubqueries => false; + + public override bool IsUniqueConstraintViolationException(DbUpdateException exception) => + exception.InnerException is MySqlException { Number: UniqueConstraintViolationErrorCode }; + + /// + /// MySQL has a limit of row size - 65535 bytes + /// So we map string, string[] and URI, which are longer than 256 symbols to longtext MySQL type + /// See: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/1606 + /// + /// EF Core model builder + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + var longtextProperties = builder.Model + .GetEntityTypes() + .SelectMany(e => e.GetProperties()) + .Where(e => + (e.ClrType == typeof(string) || e.ClrType == typeof(string[]) || e.ClrType == typeof(Uri)) && + e.GetMaxLength() > MaxAllowedVarcharLength); + + foreach (var property in longtextProperties) + { + property.SetMaxLength(null); + } + } } } diff --git a/src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj b/src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj index afc7a1214..f82f36c9b 100644 --- a/src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj +++ b/src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj @@ -1,14 +1,14 @@ - netstandard2.0 + net6.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 c6720e41b..817204e03 100644 --- a/src/BaGet.Database.SqlServer/BaGet.Database.SqlServer.csproj +++ b/src/BaGet.Database.SqlServer/BaGet.Database.SqlServer.csproj @@ -1,7 +1,7 @@ - netstandard2.0 + net6.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 c7515daac..d034d9baf 100644 --- a/src/BaGet.Database.Sqlite/BaGet.Database.Sqlite.csproj +++ b/src/BaGet.Database.Sqlite/BaGet.Database.Sqlite.csproj @@ -1,7 +1,7 @@ - netstandard2.0 + net6.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 3dc33ae66..d1b814896 100644 --- a/src/BaGet.Gcp/BaGet.Gcp.csproj +++ b/src/BaGet.Gcp/BaGet.Gcp.csproj @@ -1,14 +1,13 @@ - netstandard2.0 - + net6.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 5711a54bb..bdc31f8a6 100644 --- a/src/BaGet.Protocol/BaGet.Protocol.csproj +++ b/src/BaGet.Protocol/BaGet.Protocol.csproj @@ -1,8 +1,7 @@ - netstandard2.0 - + net6.0 NuGet;Protocol Libraries to interact with NuGet server APIs. @@ -11,7 +10,6 @@ - diff --git a/src/BaGet.Web/BaGet.Web.csproj b/src/BaGet.Web/BaGet.Web.csproj index 276e6569d..74bb958dd 100644 --- a/src/BaGet.Web/BaGet.Web.csproj +++ b/src/BaGet.Web/BaGet.Web.csproj @@ -1,8 +1,7 @@  - netcoreapp3.1 - + net6.0 NuGet BaGet's NuGet server implementation BaGet.Web @@ -15,8 +14,8 @@ - - + + diff --git a/src/BaGet.Web/Extensions/IServiceCollectionExtensions.cs b/src/BaGet.Web/Extensions/IServiceCollectionExtensions.cs index 39964850d..42125fb15 100644 --- a/src/BaGet.Web/Extensions/IServiceCollectionExtensions.cs +++ b/src/BaGet.Web/Extensions/IServiceCollectionExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Serialization; using BaGet.Core; using BaGet.Web; using Microsoft.AspNetCore.Mvc; @@ -16,10 +17,9 @@ public static IServiceCollection AddBaGetWebApplication( .AddRouting(options => options.LowercaseUrls = true) .AddControllers() .AddApplicationPart(typeof(PackageContentController).Assembly) - .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .AddJsonOptions(options => { - options.JsonSerializerOptions.IgnoreNullValues = true; + options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; }); services.AddRazorPages(); diff --git a/src/BaGet.Web/Pages/Index.cshtml b/src/BaGet.Web/Pages/Index.cshtml index 303e1c0c5..4c724e672 100644 --- a/src/BaGet.Web/Pages/Index.cshtml +++ b/src/BaGet.Web/Pages/Index.cshtml @@ -188,7 +188,7 @@ else { "divider1", "-" }, { "header1", ".NET" }, - + { "net6.0", ".NET 6.0" }, { "net5.0", ".NET 5.0" }, { "divider2", "-" }, diff --git a/src/BaGet/BaGet.csproj b/src/BaGet/BaGet.csproj index 880268ce1..59da0f4d2 100644 --- a/src/BaGet/BaGet.csproj +++ b/src/BaGet/BaGet.csproj @@ -1,13 +1,16 @@ - netcoreapp3.1 + net6.0 - + - + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 919be1428..dd834f3a0 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -15,7 +15,7 @@ true - 7.2 + 10 $(NoWarn);1591 @@ -31,20 +31,20 @@ snupkg - - true - - - 3.1.18 - 3.1.18 - 3.1.18 - 5.10.0 + 6.0.1 + 6.0.1 + 6.0.0 + 6.1.0 + + + + true - + diff --git a/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj b/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj index 50ca5e849..c4e7361a0 100644 --- a/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj +++ b/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0 diff --git a/tests/BaGet.Core.Tests/Metadata/RegistrationBuilderTests.cs b/tests/BaGet.Core.Tests/Metadata/RegistrationBuilderTests.cs index 361257401..5ad31a4da 100644 --- a/tests/BaGet.Core.Tests/Metadata/RegistrationBuilderTests.cs +++ b/tests/BaGet.Core.Tests/Metadata/RegistrationBuilderTests.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using Moq; @@ -20,7 +21,6 @@ public void TheRegistrationIndexResponseIsSortedByVersion() { // Arrange var packageId = "BaGet.Test"; - var authors = new string[] { "test" }; var packages = new List { @@ -52,14 +52,15 @@ public void TheRegistrationIndexResponseIsSortedByVersion() /// Create a fake with the minimum metadata needed by the . /// private Package GetTestPackage(string packageId, string version) - { + { return new Package { Id = packageId, - Authors = new string[] { "test" }, - PackageTypes = new List { new PackageType { Name = "test" } }, - Dependencies = new List { }, + Authors = new[] { "test" }, + PackageTypes = new List { new() { Name = "test" } }, + Dependencies = new List(), Version = new NuGetVersion(version), + Published = new DateTime(2022, 01, 01) }; } } diff --git a/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj b/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj index 83f963a35..c7b9edcbf 100644 --- a/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj +++ b/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0 diff --git a/tests/BaGet.Tests/BaGet.Tests.csproj b/tests/BaGet.Tests/BaGet.Tests.csproj index 4f70442a9..195a64d47 100644 --- a/tests/BaGet.Tests/BaGet.Tests.csproj +++ b/tests/BaGet.Tests/BaGet.Tests.csproj @@ -1,8 +1,7 @@  - netcoreapp3.1 - 8.0 + net6.0 @@ -10,7 +9,7 @@ - + diff --git a/tests/BaGet.Web.Tests/BaGet.Web.Tests.csproj b/tests/BaGet.Web.Tests/BaGet.Web.Tests.csproj index fb144a8fc..b4ad31721 100644 --- a/tests/BaGet.Web.Tests/BaGet.Web.Tests.csproj +++ b/tests/BaGet.Web.Tests/BaGet.Web.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index eca9a9007..b2c002ada 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -1,7 +1,7 @@ - 7.2 + 10 false @@ -12,21 +12,20 @@ - 3.1.18 - 12.0.2 - 5.10.0 - 2.4.1 + 6.0.1 + 6.0.0 + 6.1.0 - + all runtime; build; native; contentfiles; analyzers - - - - + + + + all runtime; build; native; contentfiles; analyzers