Skip to content

Commit

Permalink
Upgrade to net8
Browse files Browse the repository at this point in the history
Update to use Directory.Packages.props
  • Loading branch information
ardalis committed Jul 5, 2024
1 parent d215301 commit 95ea472
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 57 deletions.
2 changes: 2 additions & 0 deletions ApiProjectTemplates.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Solution Items", "_Solution Items", "{3DCCFC81-5742-499C-BFBE-6CFA21DB20BF}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "API Projects", "API Projects", "{BF524179-7DDB-4E90-8E23-8D738F60347C}"
Expand Down
12 changes: 12 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<!--<TreatWarningsAsErrors>true</TreatWarningsAsErrors>-->
<TargetFramework>net8.0</TargetFramework>
<!--<Nullable>enable</Nullable>-->
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup>
<NoWarn>1591</NoWarn> <!-- Remove this to turn on warnings for missing XML Comments -->
</PropertyGroup>
</Project>
55 changes: 55 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<Project>
<ItemGroup>
<PackageVersion Include="Ardalis.ApiEndpoints" Version="4.1.0" />
<PackageVersion Include="Ardalis.ApiEndpoints.Swashbuckle" Version="4.1.0" />
<PackageVersion Include="Ardalis.GuardClauses" Version="4.5.0" />
<PackageVersion Include="Ardalis.HttpClientTestExtensions" Version="4.2.0" />
<PackageVersion Include="Ardalis.ListStartupServices" Version="1.1.4" />
<PackageVersion Include="Ardalis.Result" Version="9.1.0" />
<PackageVersion Include="Ardalis.Result.AspNetCore" Version="8.0.0" />
<PackageVersion Include="Ardalis.RouteAndBodyModelBinding" Version="0.0.2" />
<PackageVersion Include="Ardalis.SharedKernel" Version="1.4.0" />
<PackageVersion Include="Ardalis.SmartEnum" Version="8.0.0" />
<PackageVersion Include="Ardalis.Specification" Version="8.0.0" />
<PackageVersion Include="Ardalis.Specification.EntityFrameworkCore" Version="8.0.0" />
<PackageVersion Include="Autofac" Version="8.0.0" />
<PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
<PackageVersion Include="Automapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="FastEndpoints" Version="5.27.0" />
<PackageVersion Include="FastEndpoints.ApiExplorer" Version="2.2.0" />
<PackageVersion Include="FastEndpoints.Swagger" Version="5.23.0" />
<PackageVersion Include="FastEndpoints.Swagger.Swashbuckle" Version="2.2.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="MailKit" Version="4.4.0" />
<PackageVersion Include="MediatR" Version="12.3.0" />
<PackageVersion Include="Microsoft.AspNetCore.JsonPatch" Version="8.0.6" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.6" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.6" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.6" />
<PackageVersion Include="Microsoft.Data.Sqlite.Core" Version="8.0.6" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.6" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.6" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.1" />
<PackageVersion Include="MinimalApi.Endpoint" Version="1.3.0" />
<PackageVersion Include="Moq" Version="4.20.70" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="ReportGenerator" Version="5.2.2" />
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageVersion Include="SQLite" Version="3.13.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageVersion Include="Swashbuckle.AspNetCore.Annotations" Version="6.6.2" />
<PackageVersion Include="xunit" Version="2.8.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.1" />
</ItemGroup>
</Project>
22 changes: 11 additions & 11 deletions api_templates/APIProjectTests/APIEndpointsProjectTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
Expand All @@ -26,19 +26,19 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Ardalis.HttpClientTestExtensions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="SQLite" Version="3.13.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Ardalis.HttpClientTestExtensions" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="SQLite" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" >
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
6 changes: 1 addition & 5 deletions api_templates/APIProjectTests/Endpoints/GetById_Endpoint.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
using System.Text.Json;
using ApiBestPractices.Endpoints.Endpoints.Authors;
using BackendData;
using BackendData.DataAccess;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand All @@ -13,18 +13,18 @@


<ItemGroup>
<PackageReference Include="Ardalis.ApiEndpoints" Version="4.0.1" />
<PackageReference Include="Ardalis.ApiEndpoints.Swashbuckle" Version="4.0.1" />
<PackageReference Include="Ardalis.Result" Version="4.0.0" />
<PackageReference Include="Ardalis.RouteAndBodyModelBinding" Version="0.0.2" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="6.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.3">
<PackageReference Include="Ardalis.ApiEndpoints" />
<PackageReference Include="Ardalis.ApiEndpoints.Swashbuckle" />
<PackageReference Include="Ardalis.Result"/>
<PackageReference Include="Ardalis.RouteAndBodyModelBinding" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ namespace ApiBestPractices.Endpoints.Endpoints.Account;

public class TokenResponse
{
public AccessToken AccessToken { get; set; }
public AccessToken AccessToken { get; set; } = default!;
}
20 changes: 11 additions & 9 deletions api_templates/BackendData/BackendData.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ardalis.Result" Version="4.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" PrivateAssets="all" Version="6.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.3" />
<PackageReference Include="SQLite" Version="3.13.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />

<PackageReference Include="Ardalis.Result" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
<PackageReference Include="SQLite" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Microsoft.Extensions.Options" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion api_templates/BackendData/DataAccess/EfRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public EfRepository(AppDbContext dbContext)
_dbContext = dbContext;
}

public virtual async Task<T> GetByIdAsync(int id, CancellationToken cancellationToken)
public virtual async Task<T?> GetByIdAsync(int id, CancellationToken cancellationToken)
{
return await _dbContext.Set<T>().FirstOrDefaultAsync(a => a.Id == id, cancellationToken);
}
Expand Down
2 changes: 1 addition & 1 deletion api_templates/BackendData/DomainModel/IAsyncRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace BackendData;
/// <typeparam name="T"></typeparam>
public interface IAsyncRepository<T> where T : BaseEntity
{
Task<T> GetByIdAsync(int id, CancellationToken cancellationToken);
Task<T?> GetByIdAsync(int id, CancellationToken cancellationToken);

Task<IReadOnlyList<T>> ListAllAsync(CancellationToken cancellationToken);

Expand Down
6 changes: 3 additions & 3 deletions api_templates/BackendData/Security/TokenOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public class TokenOptions
{
public string Audience { get; set; }
public string Issuer { get; set; }
public string Audience { get; set; } = String.Empty;
public string Issuer { get; set; } = String.Empty;
public long AccessTokenExpiration { get; set; }
public string Secret { get; set; }
public string Secret { get; set; } = String.Empty;
}
2 changes: 1 addition & 1 deletion api_templates/controllers/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

// add application services
builder.Services.AddScoped<IAuthorService, AuthorService>();
builder.Services.AddMediatR(typeof(IAuthorService));
builder.Services.AddMediatR(config => config.RegisterServicesFromAssembly(typeof(IAuthorService).Assembly));

// configure autofac - necessary for MediatR property on base controller class example
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
Expand Down
10 changes: 5 additions & 5 deletions api_templates/controllers/controllers.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="6.4.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="10.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
<PackageReference Include="Autofac" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" />
<PackageReference Include="MediatR" />
<PackageReference Include="Swashbuckle.AspNetCore" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions api_templates/fastendpoints/FastEndpointsAPI.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
<PackageReference Include="FastEndpoints" Version="4.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="FastEndpoints" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion api_templates/minimal/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddEndpointsMetadataProviderApiExplorer();
// builder.Services.AddEndpointsMetadataProviderApiExplorer(); only needed in NET6
builder.Services.AddSwaggerGen(config => config.EnableAnnotations());

builder.Services.AddAuthentication();
Expand Down
12 changes: 6 additions & 6 deletions api_templates/minimal/minimal.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="6.0.3" />
<PackageReference Include="MinimalApi.Endpoint" Version="1.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
<PackageReference Include="MinimalApis.Extensions" Version="0.7.0-pre.20220528.28" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.3.1" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" />
<PackageReference Include="MinimalApi.Endpoint" />
<PackageReference Include="Swashbuckle.AspNetCore" />
<!--<PackageReference Include="MinimalApis.Extensions" Version="0.7.0-pre.20220528.28" />-->
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" />
</ItemGroup>

<ItemGroup>
Expand Down
Binary file added demos.zip
Binary file not shown.

0 comments on commit 95ea472

Please sign in to comment.