Skip to content

Commit

Permalink
Feature: Migrate to .NET 8 (#2669)
Browse files Browse the repository at this point in the history
  • Loading branch information
hocinehacherouf authored Feb 25, 2024
1 parent d09dc72 commit 31fb98a
Show file tree
Hide file tree
Showing 27 changed files with 93 additions and 110 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-open-api-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Restore Dotnet tools
run: dotnet tool restore
Expand All @@ -34,7 +34,7 @@ jobs:
working-directory: src/

- name: Generate Open API documentation
run: dotnet swagger tofile --output ./swagger.json IoTHub.Portal.Server/bin/Debug/net7.0/IoTHub.Portal.Server.dll v1
run: dotnet swagger tofile --output ./swagger.json IoTHub.Portal.Server/bin/Debug/net8.0/IoTHub.Portal.Server.dll v1
working-directory: src/
env:
CloudProvider: Azure
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- uses: actions/cache@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
4 changes: 2 additions & 2 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
Expand All @@ -12,7 +12,7 @@ RUN rm packages-microsoft-prod.deb
RUN apt-get update; \
apt-get install -y apt-transport-https && \
apt-get update && \
apt-get install -y dotnet-sdk-7.0
apt-get install -y dotnet-sdk-8.0

FROM build AS builder
ARG BUILD_VERSION=1.2.3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Azure.Devices" Version="1.39.1" />
<PackageReference Include="Microsoft.Azure.Devices.Provisioning.Service" Version="1.18.4" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.4">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
12 changes: 6 additions & 6 deletions src/IoTHub.Portal.Client/IoTHub.Portal.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand All @@ -23,7 +23,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.4">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -34,12 +34,12 @@
</PackageReference>
<PackageReference Include="MudBlazor" Version="6.11.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Net.Http.Json" Version="7.0.1" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
<PackageReference Include="Tewr.Blazor.FileReader" Version="3.3.2.23201" />

<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.15" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="7.0.15" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.2" />
<PackageReference Include="Toolbelt.Blazor.LoadingBar" Version="14.0.0" />
</ItemGroup>

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

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/IoTHub.Portal.Domain/IoTHub.Portal.Domain.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.4">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>e60ac7af-e305-49c5-8545-40f960d5188d</UserSecretsId>
Expand Down Expand Up @@ -113,37 +113,37 @@
<PackageReference Include="Azure.Messaging.EventHubs.Processor" Version="5.10.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
<PackageReference Include="CsvHelper" Version="30.1.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="7.0.13" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Server.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.39.1" />
<PackageReference Include="Microsoft.Azure.Devices.Provisioning.Service" Version="1.18.4" />
<PackageReference Include="Microsoft.Azure.Devices.Shared" Version="1.30.4" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.4">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.15" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="7.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.15">
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.15" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
<PackageReference Include="Polly.Extensions.Http" Version="3.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0" />
<PackageReference Include="prometheus-net" Version="8.2.1" />
<PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.8.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.2" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.8" />
<PackageReference Include="EntityFrameworkCore.Exceptions.PostgreSQL" Version="6.0.3" />
<PackageReference Include="EntityFrameworkCore.Exceptions.PostgreSQL" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IoTHub.Portal.Application\IoTHub.Portal.Application.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public override async Task DeleteDevice(string deviceId)
}
catch (AmazonIoTException e)
{
this.logger.LogWarning("Can not detach Thing principal because it doesn't exist in AWS IoT", e);
this.logger.LogWarning(e, "Can not detach Thing principal because it doesn't exist in AWS IoT");
}

try
Expand All @@ -140,19 +140,19 @@ public override async Task DeleteDevice(string deviceId)
}
catch (AmazonIoTException e)
{
this.logger.LogWarning("Can not delete the thing because it doesn't exist in AWS IoT", e);
this.logger.LogWarning(e, "Can not delete the thing because it doesn't exist in AWS IoT");
}

}
catch (AmazonIoTException e)
{
this.logger.LogWarning("Can not retreive Thing because it doesn't exist in AWS IoT", e);
this.logger.LogWarning(e, "Can not retreive Thing because it doesn't exist in AWS IoT");
}

}
catch (AmazonIoTException e)
{
this.logger.LogWarning("Can not delete the device because it doesn't exist in AWS IoT", e);
this.logger.LogWarning(e, "Can not delete the device because it doesn't exist in AWS IoT");

}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ public async Task DeleteEdgeDeviceAsync(string deviceId)
await this.externalDeviceService.RemoveDeviceCredentials(device);
await this.externalDeviceService.DeleteDevice(device.DeviceName);
}
catch (AmazonIoTException ex)
catch (AmazonIoTException e)
{
this.logger.LogWarning("Can not delete the edge device because it doesn't exist in AWS IoT", ex);
this.logger.LogWarning(e, "Can not delete the edge device because it doesn't exist in AWS IoT");

}
finally
Expand All @@ -157,8 +157,8 @@ public async Task DeleteEdgeDeviceAsync(string deviceId)
await this.unitOfWork.SaveAsync();
}

}

}

/// <summary>
/// Get edge device with its modules.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public async Task DeleteDevice(string deviceId)
}
catch (ResourceNotFoundException e)
{
this.logger.LogWarning("Unable to delete the thing because it doesn't exist", e);
this.logger.LogWarning(e, "Unable to delete the thing because it doesn't exist");
}

}
Expand Down Expand Up @@ -727,7 +727,7 @@ public async Task RemoveDeviceCredentials(IoTEdgeDevice device)
}
catch (AmazonIoTException e)
{
this.logger.LogWarning("Unable to List Thing principal due to an error in the Amazon IoT API.", e);
this.logger.LogWarning(e, "Unable to List Thing principal due to an error in the Amazon IoT API.");
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/IoTHub.Portal.MySql/IoTHub.Portal.MySql.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -12,12 +12,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.15">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.15" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/IoTHub.Portal.Postgres/IoTHub.Portal.Postgres.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -17,12 +17,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.15">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.15" />
<PackageReference Include="EntityFrameworkCore.Exceptions.PostgreSQL" Version="6.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.2" />
<PackageReference Include="EntityFrameworkCore.Exceptions.PostgreSQL" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public async Task CreateConfig(DeviceConfig deviceConfig)
await this.deviceConfigurationsService.CreateConfigurationAsync(deviceConfig);
}

[HttpPut("{configurationId}", Name = "PUT Update Device configuration")]
[HttpPut(Name = "PUT Update Device configuration")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task UpdateConfig(DeviceConfig deviceConfig)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public override Task<IActionResult> Post(DeviceModelDto deviceModel)
/// </summary>
/// <param name="deviceModel">The device model.</param>
/// <returns>The action result.</returns>
[HttpPut("{id}", Name = "PUT Update the device model")]
[HttpPut(Name = "PUT Update the device model")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public async Task<IActionResult> CreateEdgeDeviceAsync(IoTEdgeDevice edgeDevice)
/// Updates the device.
/// </summary>
/// <param name="edgeDevice">The IoT Edge device.</param>
[HttpPut("{deviceId}", Name = "PUT Update IoT Edge")]
[HttpPut(Name = "PUT Update IoT Edge")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<IActionResult> UpdateDeviceAsync(IoTEdgeDevice edgeDevice)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public override Task<IActionResult> Post(LoRaDeviceModelDto deviceModelDto)
/// </summary>
/// <param name="deviceModelDto">The device model.</param>
/// <returns>The action result.</returns>
[HttpPut("{id}", Name = "PUT Update the LoRaWAN device model")]
[HttpPut(Name = "PUT Update the LoRaWAN device model")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
Expand Down
4 changes: 2 additions & 2 deletions src/IoTHub.Portal.Server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

ARG BUILD_VERSION=1.0.0-dev

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app

ENV ASPNETCORE_URLS=http://+:80;https://+:443
Expand All @@ -17,7 +17,7 @@ RUN rm packages-microsoft-prod.deb
RUN apt-get update; \
apt-get install -y apt-transport-https && \
apt-get update && \
apt-get install -y dotnet-sdk-7.0
apt-get install -y dotnet-sdk-8.0

FROM build AS builder
WORKDIR /src
Expand Down
Loading

0 comments on commit 31fb98a

Please sign in to comment.