Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to .NET 6 #717

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 mmcr.microsoft.com/dotnet/sdk:6.0 AS build
mishamyte marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /src
COPY /src .
RUN dotnet restore BaGet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<NoWarn>IDE0007</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion samples/BaGetWebApplication/BaGetWebApplication.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/BaGet.Aliyun/BaGet.Aliyun.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<PropertyGroup>
<PackageTags>NuGet;Alibaba;Cloud</PackageTags>
<Description>The libraries to host BaGet on Alibaba Cloud (Aliyun).</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.9.1" />
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 4 additions & 5 deletions src/BaGet.Aws/BaGet.Aws.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>

<TargetFramework>net6.0</TargetFramework>
<PackageTags>NuGet;Amazon;Cloud</PackageTags>
<Description>The libraries to host BaGet on AWS.</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.S3" Version="3.3.110.20" />
<PackageReference Include="AWSSDK.SecurityToken" Version="3.3.104.27" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="AWSSDK.S3" Version="3.7.7.11" />
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.1.105" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
mishamyte marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions src/BaGet.Azure/BaGet.Azure.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>

<TargetFramework>net6.0</TargetFramework>
<PackageTags>NuGet;Azure;Cloud</PackageTags>
<Description>The libraries to host BaGet on Azure.</Description>
</PropertyGroup>
Expand All @@ -11,7 +10,7 @@
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.Search" Version="5.0.1" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="9.4.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 7 additions & 8 deletions src/BaGet.Core/BaGet.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>

<TargetFramework>net6.0</TargetFramework>
<PackageTags>NuGet</PackageTags>
<Description>The core libraries that power BaGet.</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="$(MicrosoftEntityFrameworkCorePackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="NuGet.Protocol" Version="$(NuGetPackageVersion)" />
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
<PackageReference Include="NuGet.Protocol" Version="6.0.0" />
<PackageReference Include="System.Reflection.Metadata" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/BaGet.Database.MySql/BaGet.Database.MySql.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>

<PackageTags>NuGet</PackageTags>
<Description>The libraries to host BaGet on MySQL.</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/BaGet.Database.MySql/MySqlApplicationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static BaGetApplication AddMySqlDatabase(this BaGetApplication app)
{
var databaseOptions = provider.GetRequiredService<IOptionsSnapshot<DatabaseOptions>>();

options.UseMySql(databaseOptions.Value.ConnectionString);
options.UseMySql(databaseOptions.Value.ConnectionString, ServerVersion.AutoDetect(databaseOptions.Value.ConnectionString));
});

return app;
Expand Down
5 changes: 2 additions & 3 deletions src/BaGet.Database.MySql/MySqlContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using BaGet.Core;
using Microsoft.EntityFrameworkCore;
using MySql.Data.MySqlClient;
using MySqlConnector;

namespace BaGet.Database.MySql
{
Expand All @@ -17,8 +17,7 @@ public MySqlContext(DbContextOptions<MySqlContext> options) : base(options)

public override bool IsUniqueConstraintViolationException(DbUpdateException exception)
{
return exception.InnerException is MySqlException mysqlException &&
mysqlException.Number == UniqueConstraintViolationErrorCode;
return exception.InnerException is MySqlException {Number: UniqueConstraintViolationErrorCode};
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>

<PackageTags>NuGet</PackageTags>
<Description>The libraries to host BaGet on PostgreSQL.</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.1.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/BaGet.Database.SqlServer/BaGet.Database.SqlServer.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>

<PackageTags>NuGet</PackageTags>
<Description>The libraries to host BaGet on SQL Server.</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(MicrosoftEntityFrameworkCorePackageVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/BaGet.Database.Sqlite/BaGet.Database.Sqlite.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>

<PackageTags>NuGet</PackageTags>
<Description>The libraries to host BaGet on SQLite.</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="$(MicrosoftEntityFrameworkCorePackageVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions src/BaGet.Gcp/BaGet.Gcp.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>

<TargetFramework>net6.0</TargetFramework>
<PackageTags>NuGet;Google;Cloud</PackageTags>
<Description>The libraries to host BaGet on the Google Cloud Platform.</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Cloud.Storage.V1" Version="2.2.1" />
<PackageReference Include="Google.Cloud.Storage.V1" Version="3.6.0" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 5 additions & 6 deletions src/BaGet.Protocol/BaGet.Protocol.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>

<TargetFramework>net6.0</TargetFramework>
<PackageTags>NuGet;Protocol</PackageTags>
<Description>Libraries to interact with NuGet server APIs.</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="NuGet.Frameworks" Version="$(NuGetPackageVersion)" />
<PackageReference Include="NuGet.Versioning" Version="$(NuGetPackageVersion)" />
<PackageReference Include="System.Text.Json" Version="4.7.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="NuGet.Frameworks" Version="6.0.0" />
<PackageReference Include="NuGet.Versioning" Version="6.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.1" />
mishamyte marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>

</Project>
5 changes: 2 additions & 3 deletions src/BaGet.Web/BaGet.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<TargetFramework>net6.0</TargetFramework>
<PackageTags>NuGet</PackageTags>
<Description>BaGet's NuGet server implementation</Description>
<RootNamespace>BaGet.Web</RootNamespace>
Expand All @@ -15,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Humanizer" Version="2.11.10" />
<PackageReference Include="Humanizer" Version="2.13.14" />
<PackageReference Include="Markdig" Version="0.26.0" />
</ItemGroup>

Expand Down
11 changes: 7 additions & 4 deletions src/BaGet/BaGet.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="$(MicrosoftAspNetCorePackageVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="$(MicrosoftEntityFrameworkCorePackageVersion)" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Copy link
Owner

@loic-sharma loic-sharma Feb 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason behind this change for Microsoft.EntityFrameworkCore.Design?

Copy link
Author

@mishamyte mishamyte Feb 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is to define it as design-time dependency for concrete project and does not include it's dll as a part of artifacts or as a part of implicit dependency to other projects

(https://docs.microsoft.com/en-us/ef/core/cli/services#referencing-microsoftentityframeworkcoredesign)

</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 2 additions & 10 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<!-- Compiler properties -->
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>7.2</LangVersion>
<LangVersion>10</LangVersion>

<!-- Don't warn if there are missing XMl comment for publicly visible type or member-->
<NoWarn>$(NoWarn);1591</NoWarn>
Expand All @@ -35,16 +35,8 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<!-- NuGet dependencies shared across projects -->
<PropertyGroup>
<MicrosoftAspNetCorePackageVersion>3.1.18</MicrosoftAspNetCorePackageVersion>
<MicrosoftEntityFrameworkCorePackageVersion>3.1.18</MicrosoftEntityFrameworkCorePackageVersion>
<MicrosoftExtensionsPackageVersion>3.1.18</MicrosoftExtensionsPackageVersion>
<NuGetPackageVersion>5.10.0</NuGetPackageVersion>
</PropertyGroup>

<ItemGroup Condition="'$(DOTNET_RUNNING_IN_CONTAINER)' == ''">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 4 additions & 5 deletions tests/BaGet.Tests/BaGet.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>8.0</LangVersion>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
<PackageReference Include="NuGet.Protocol" Version="$(NuGetPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(MicrosoftAspNetCorePackageVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NuGet.Protocol" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/BaGet.Web.Tests/BaGet.Web.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading