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 9 #629

Merged
merged 8 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 4 additions & 6 deletions .github/workflows/account-management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Restore .NET tools
working-directory: application
run: |
dotnet tool restore &&
dotnet workload install aspire
dotnet tool restore

- name: Restore .NET dependencies
working-directory: application
Expand Down Expand Up @@ -160,13 +159,12 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Restore .NET tools
working-directory: application
run: |
dotnet tool restore &&
dotnet workload install aspire
dotnet tool restore

- name: Restore .NET dependencies
working-directory: application
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/app-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Restore .NET tools
working-directory: application
run: |
dotnet tool restore &&
dotnet workload install aspire
dotnet tool restore

- name: Restore .NET dependencies
working-directory: application
Expand Down Expand Up @@ -108,13 +107,12 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Restore .NET tools
working-directory: application
run: |
dotnet tool restore &&
dotnet workload install aspire
dotnet tool restore

- name: Restore .NET dependencies
working-directory: application
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/back-office.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Restore .NET tools
working-directory: application
run: |
dotnet tool restore &&
dotnet workload install aspire
dotnet tool restore

- name: Restore .NET dependencies
working-directory: application
Expand Down Expand Up @@ -160,13 +159,12 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Restore .NET tools
working-directory: application
run: |
dotnet tool restore &&
dotnet workload install aspire
dotnet tool restore

- name: Restore .NET dependencies
working-directory: application
Expand Down
2 changes: 1 addition & 1 deletion application/AppGateway/AppGateway.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>PlatformPlatform.AppGateway</AssemblyName>
<RootNamespace>PlatformPlatform.AppGateway</RootNamespace>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion application/AppGateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine

WORKDIR /app
COPY ./AppGateway/publish .
Expand Down
2 changes: 1 addition & 1 deletion application/AppHost/AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
Expand Down
78 changes: 12 additions & 66 deletions application/AppHost/SslCertificateManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Extensions.Configuration;
Expand All @@ -10,10 +9,7 @@

public static class SslCertificateManager
{
public static readonly bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

private static string UserSecretsId =>
Assembly.GetEntryAssembly()!.GetCustomAttribute<UserSecretsIdAttribute>()!.UserSecretsId;
private static string UserSecretsId => Assembly.GetEntryAssembly()!.GetCustomAttribute<UserSecretsIdAttribute>()!.UserSecretsId;

public static string CreateSslCertificateIfNotExists(this IDistributedApplicationBuilder builder)
{
Expand All @@ -24,9 +20,13 @@
?? builder.CreateStablePassword(certificatePasswordKey).Resource.Value;

var certificateLocation = GetCertificateLocation("localhost");
if (!IsValidCertificate(certificatePassword, certificateLocation))
try
{
X509CertificateLoader.LoadPkcs12FromFile(certificateLocation, certificatePassword);
}
catch (CryptographicException)
{
CreateNewSelfSignedDeveloperCertificate(certificatePassword, certificateLocation);
CreateNewSelfSignedDeveloperCertificate(certificateLocation, certificatePassword);
}

return certificatePassword;
Expand All @@ -38,77 +38,23 @@
return $"{userFolder}/.aspnet/dev-certs/https/{domain}.pfx";
}

private static bool IsValidCertificate(string? password, string certificateLocation)
{
if (!File.Exists(certificateLocation))
{
return false;
}

if (IsWindows)
{
try
{
// Try to load the certificate with the provided password
_ = new X509Certificate2(certificateLocation, password);
return true;
}
catch (CryptographicException)
{
// If a CryptographicException is thrown, the password is invalid
// Ignore the exception and return false
}
}
else
{
var certificateValidation = StartProcess(new ProcessStartInfo
{
FileName = "openssl",
Arguments = $"pkcs12 -in {certificateLocation} -passin pass:{password} -nokeys",
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
}
);

if (certificateValidation.Contains("--BEGIN CERTIFICATE--"))
{
return true;
}
}

Console.WriteLine($"Certificate {certificateLocation} exists, but password {password} was invalid. Creating a new certificate.");
return false;
}

private static void CreateNewSelfSignedDeveloperCertificate(string password, string certificateLocation)
private static void CreateNewSelfSignedDeveloperCertificate(string certificateLocation, string password)
{
if (File.Exists(certificateLocation))
{
Console.WriteLine($"Certificate {certificateLocation} exists, but password {password} was invalid. Creating a new certificate.");

File.Delete(certificateLocation);
}

StartProcess(new ProcessStartInfo
Process.Start(new ProcessStartInfo
{
FileName = "dotnet",

Check warning on line 52 in application/AppHost/SslCertificateManager.cs

View workflow job for this annotation

GitHub Actions / Build and Test

Make sure the "PATH" used to find this command includes only what you intend. (https://rules.sonarsource.com/csharp/RSPEC-4036)

Check warning on line 52 in application/AppHost/SslCertificateManager.cs

View workflow job for this annotation

GitHub Actions / Build and Test

Make sure the "PATH" used to find this command includes only what you intend. (https://rules.sonarsource.com/csharp/RSPEC-4036)

Check warning on line 52 in application/AppHost/SslCertificateManager.cs

View workflow job for this annotation

GitHub Actions / Build and Test

Make sure the "PATH" used to find this command includes only what you intend. (https://rules.sonarsource.com/csharp/RSPEC-4036)

Check warning on line 52 in application/AppHost/SslCertificateManager.cs

View workflow job for this annotation

GitHub Actions / Build and Test

Make sure the "PATH" used to find this command includes only what you intend. (https://rules.sonarsource.com/csharp/RSPEC-4036)
Arguments = $"dev-certs https --trust -ep {certificateLocation} -p {password}",
RedirectStandardOutput = false,
RedirectStandardError = false,
UseShellExecute = false
}
);
}

private static string StartProcess(ProcessStartInfo processStartInfo)
{
var process = Process.Start(processStartInfo)!;

var output = string.Empty;
if (processStartInfo.RedirectStandardOutput) output += process.StandardOutput.ReadToEnd();
if (processStartInfo.RedirectStandardError) output += process.StandardError.ReadToEnd();

process.WaitForExit();

return output;
)!.WaitForExit();
}
}
6 changes: 3 additions & 3 deletions application/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
<PackageVersion Include="Meziantou.Xunit.ParallelTestFramework" Version="2.3.0" />
<PackageVersion Include="Microsoft.ApplicationInsights" Version="2.22.0" />
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.ApiExplorer" Version="2.2.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.10" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
<PackageVersion Include="Microsoft.Extensions.ApiDescription.Server" Version="8.0.10">
<PackageVersion Include="Microsoft.Extensions.ApiDescription.Server" Version="9.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>PlatformPlatform.AccountManagement.Api</AssemblyName>
<RootNamespace>PlatformPlatform.AccountManagement.Api</RootNamespace>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion application/account-management/Api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine

RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>PlatformPlatform.AccountManagement</AssemblyName>
<RootNamespace>PlatformPlatform.AccountManagement</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>PlatformPlatform.AccountManagement.Tests</AssemblyName>
<RootNamespace>PlatformPlatform.AccountManagement.Tests</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<ShouldRunNpmInstall>false</ShouldRunNpmInstall>
<ShouldRunBuildScript>false</ShouldRunBuildScript>
<TargetFrameworkMoniker>net8.0</TargetFrameworkMoniker>
<TargetFrameworkMoniker>net9.0</TargetFrameworkMoniker>
<DefaultItemExcludes>$(DefaultItemExcludes);dist\**;*.config.*;*.d.ts</DefaultItemExcludes>
<NpmInstallCheck>$(MSBuildProjectDirectory)\..\..\package-lock.json</NpmInstallCheck>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>PlatformPlatform.AccountManagement.Workers</AssemblyName>
<RootNamespace>PlatformPlatform.AccountManagement.Workers</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
2 changes: 1 addition & 1 deletion application/account-management/Workers/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine

RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
Expand Down
2 changes: 1 addition & 1 deletion application/back-office/Api/BackOffice.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>PlatformPlatform.BackOffice.Api</AssemblyName>
<RootNamespace>PlatformPlatform.BackOffice.Api</RootNamespace>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion application/back-office/Api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine

RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
Expand Down
2 changes: 1 addition & 1 deletion application/back-office/Core/BackOffice.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>PlatformPlatform.BackOffice</AssemblyName>
<RootNamespace>PlatformPlatform.BackOffice</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
2 changes: 1 addition & 1 deletion application/back-office/Tests/BackOffice.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>PlatformPlatform.BackOffice.Tests</AssemblyName>
<RootNamespace>PlatformPlatform.BackOffice.Tests</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
2 changes: 1 addition & 1 deletion application/back-office/WebApp/BackOffice.WebApp.esproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<ShouldRunNpmInstall>false</ShouldRunNpmInstall>
<ShouldRunBuildScript>false</ShouldRunBuildScript>
<TargetFrameworkMoniker>net8.0</TargetFrameworkMoniker>
<TargetFrameworkMoniker>net9.0</TargetFrameworkMoniker>
<DefaultItemExcludes>$(DefaultItemExcludes);dist\**;*.config.*;*.d.ts</DefaultItemExcludes>
<NpmInstallCheck>$(MSBuildProjectDirectory)\..\..\package-lock.json</NpmInstallCheck>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion application/back-office/Workers/BackOffice.Workers.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>PlatformPlatform.BackOffice.Workers</AssemblyName>
<RootNamespace>PlatformPlatform.BackOffice.Workers</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
2 changes: 1 addition & 1 deletion application/back-office/Workers/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine

RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
Expand Down
2 changes: 1 addition & 1 deletion application/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.400",
"version": "9.0.100",
"rollForward": "latestMinor"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Azure.Storage.Blobs;
using Microsoft.ApplicationInsights.AspNetCore.Extensions;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -120,7 +121,8 @@ private static IHostApplicationBuilder AddConfigureOpenTelemetry(this IHostAppli
{
builder.Services.Configure<AspNetCoreTraceInstrumentationOptions>(options =>
{
options.Filter = httpContext =>
// ReSharper disable once RedundantLambdaParameterType
options.Filter = (HttpContext httpContext) =>
{
var requestPath = httpContext.Request.Path.ToString();

Expand Down
Loading