Skip to content

Commit

Permalink
Add .NET 9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thohng committed Mar 22, 2024
1 parent cacdc6c commit 6cc6999
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 32 deletions.
63 changes: 49 additions & 14 deletions .github/workflows/aspnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,24 @@ jobs:
name: ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET Core 8.0.x, 7.0.x, and 6.0.x
uses: actions/setup-dotnet@v3
- name: Setup .NET 8.0.x, 7.0.x and 6.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Setup .NET 9.0.x Preview
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
dotnet-quality: "preview"

- name: dotnet info
run: dotnet --info

Expand All @@ -50,7 +56,7 @@ jobs:
- name: Docker meta 6.0
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }}
id: meta60
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_HUB_REPOS }}
Expand All @@ -76,7 +82,7 @@ jobs:
- name: Docker meta 7.0
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }}
id: meta70
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_HUB_REPOS }}
Expand All @@ -98,7 +104,7 @@ jobs:
- name: Docker meta 8.0
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }}
id: meta80
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_HUB_REPOS }}
Expand All @@ -117,6 +123,28 @@ jobs:
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=570,pattern=^(\d+\.\d+)(\.\d+)?(-.+)?$,group=1
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=560,pattern=^(\d+)\.\d+(\.\d+)?(-.+)?$,group=1
- name: Docker meta 9.0
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }}
id: meta90
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_HUB_REPOS }}
netlah/echo-service-api,enable=${{ startsWith(github.ref, 'refs/tags/') }}
flavor: |
latest=auto
suffix=${{ env.TAG_SUFFIX }}
prefix=9.0-
tags: |
type=raw,enable=${{ github.event_name != 'pull_request' }},priority=699,value=${{ steps.minver.outputs.version }}
type=ref,event=branch,priority=500
type=ref,event=pr,priority=500,prefix=9.0-pr-
type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=9.0-sha-,format=short
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=600,pattern=^(\d+\.\d+(\.\d+)?(-.+)?)$,group=1
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=590,pattern=^(\d+\.\d+(\.\d+)?)(-.+)?$,group=1
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=570,pattern=^(\d+\.\d+)(\.\d+)?(-.+)?$,group=1
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=560,pattern=^(\d+)\.\d+(\.\d+)?(-.+)?$,group=1
- name: Install dependencies
run: dotnet restore

Expand All @@ -128,17 +156,17 @@ jobs:

- name: Publish
run: |
dotnet publish EchoServiceApi -c Release -f net6.0 --no-build -o artifacts/net6.0/app
dotnet publish EchoServiceApi -c Release -f net7.0 --no-build -o artifacts/net7.0/app
dotnet publish EchoServiceApi -c Release -f net8.0 --no-build -o artifacts/net8.0/app
foreach ($framework in @('net6.0', 'net7.0', 'net8.0', 'net9.0')) {
dotnet publish EchoServiceApi -c Release -f $framework --no-build -o "artifacts/$($framework)/app"
}
- name: Copy Dockerfile
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }}
shell: pwsh
run: |
Copy-Item -Recurse -Force -Path '.dockerignore',".docker-$( if ($Env:RUNNER_OS -eq 'Linux') { 'linux' } else { 'windows' } )/*" -Destination artifacts/net6.0/ -ErrorAction Stop -Verbose
Copy-Item -Recurse -Force -Path '.dockerignore',".docker-$( if ($Env:RUNNER_OS -eq 'Linux') { 'linux' } else { 'windows' } )/*" -Destination artifacts/net7.0/ -ErrorAction Stop -Verbose
Copy-Item -Recurse -Force -Path '.dockerignore',".docker-$( if ($Env:RUNNER_OS -eq 'Linux') { 'linux' } else { 'windows' } )/*" -Destination artifacts/net8.0/ -ErrorAction Stop -Verbose
foreach ($framework in @('net6.0', 'net7.0', 'net8.0', 'net9.0')) {
Copy-Item -Recurse -Force -Path '.dockerignore',".docker-$( if ($Env:RUNNER_OS -eq 'Linux') { 'linux' } else { 'windows' } )/*" -Destination "artifacts/$($framework)/" -ErrorAction Stop -Verbose
}
- name: Enabling Docker Daemon With experimental features
if: ${{ success() && runner.os == 'Linux' }}
Expand All @@ -152,11 +180,11 @@ jobs:
- name: Set up Docker Buildx
if: ${{ success() && (runner.os == 'Linux') }}
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }}
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
Expand All @@ -179,3 +207,10 @@ jobs:
run: |
$aspnetImageTag80 = if ($Env:RUNNER_OS -eq 'Linux') { '8.0-alpine' } else { '8.0-nanoserver-1809' }
./docker-build.ps1 -Context ./artifacts/net8.0 -Squash -Tags "${{ steps.meta80.outputs.tags }}" -Labels "${{ steps.meta80.outputs.labels }}" -BuildArgs "ASPNET_IMAGE_TAG=$aspnetImageTag80"
- name: Build and Push 9.0
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }}
shell: pwsh
run: |
$aspnetImageTag90 = if ($Env:RUNNER_OS -eq 'Linux') { '9.0-alpine' } else { '9.0-preview-nanoserver-1809' }
./docker-build.ps1 -Context ./artifacts/net9.0 -Squash -Tags "${{ steps.meta90.outputs.tags }}" -Labels "${{ steps.meta90.outputs.labels }}" -BuildArgs "ASPNET_IMAGE_TAG=$aspnetImageTag90"
20 changes: 18 additions & 2 deletions Common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<CurrentFrameworkVersion>6.0.26;7.0.15;8.0.1</CurrentFrameworkVersion>
<CurrentFrameworkVersion>6.0.28;7.0.17;8.0.3</CurrentFrameworkVersion>
<ImportedCommonProps>True</ImportedCommonProps>

<NET_ID>$([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework)))</NET_ID>
Expand Down Expand Up @@ -31,38 +31,54 @@
<NET_10_0 Condition="'$(NET_VER)' == '10.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_10_0>

<NET_3_1_LESS>False</NET_3_1_LESS>
<NET_3_1_UP>False</NET_3_1_UP>
<NET_5_0_LESS>False</NET_5_0_LESS>
<NET_5_0_UP>False</NET_5_0_UP>
<NET_6_0_LESS>False</NET_6_0_LESS>
<NET_6_0_UP>False</NET_6_0_UP>
<NET_7_0_LESS>False</NET_7_0_LESS>
<NET_7_0_UP>False</NET_7_0_UP>
<NET_8_0_LESS>False</NET_8_0_LESS>
<NET_8_0_UP>False</NET_8_0_UP>
<NET_9_0_LESS>False</NET_9_0_LESS>
<NET_9_0_UP>False</NET_9_0_UP>
<NET_3_1_LESS Condition="'$(NET_VER)' &lt;= '3.1' And '$(NET_ID)' == '.NETCoreApp'">True</NET_3_1_LESS>
<NET_3_1_UP Condition="'$(NET_VER)' &gt;= '3.1' And '$(NET_ID)' == '.NETCoreApp'">True</NET_3_1_UP>
<NET_5_0_LESS Condition="'$(NET_VER)' &lt; '6.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_5_0_LESS>
<NET_5_0_UP Condition="'$(NET_VER)' &gt;= '5.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_5_0_UP>
<NET_6_0_LESS Condition="'$(NET_VER)' &lt; '7.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_6_0_LESS>
<NET_6_0_UP Condition="'$(NET_VER)' &gt;= '6.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_6_0_UP>
<NET_7_0_LESS Condition="'$(NET_VER)' &lt; '8.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_7_0_LESS>
<NET_7_0_UP Condition="'$(NET_VER)' &gt;= '7.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_7_0_UP>
<NET_8_0_LESS Condition="'$(NET_VER)' &lt;= '8.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_8_0_LESS>
<NET_8_0_UP Condition="'$(NET_VER)' &gt;= '8.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_8_0_UP>

<NET_9_0_LESS Condition="'$(NET_VER)' &lt;= '9.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_9_0_LESS>
<NET_9_0_UP Condition="'$(NET_VER)' &gt;= '9.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_9_0_UP>

<NET_3_1_LESS_OR_STD>False</NET_3_1_LESS_OR_STD>
<NET_3_1_UP_OR_STD>False</NET_3_1_UP_OR_STD>
<NET_5_0_LESS_OR_STD>False</NET_5_0_LESS_OR_STD>
<NET_5_0_UP_OR_STD>False</NET_5_0_UP_OR_STD>
<NET_6_0_LESS_OR_STD>False</NET_6_0_LESS_OR_STD>
<NET_6_0_UP_OR_STD>False</NET_6_0_UP_OR_STD>
<NET_7_0_LESS_OR_STD>False</NET_7_0_LESS_OR_STD>
<NET_7_0_UP_OR_STD>False</NET_7_0_UP_OR_STD>
<NET_8_0_LESS_OR_STD>False</NET_8_0_LESS_OR_STD>
<NET_8_0_UP_OR_STD>False</NET_8_0_UP_OR_STD>
<NET_9_0_LESS_OR_STD>False</NET_9_0_LESS_OR_STD>
<NET_9_0_UP_OR_STD>False</NET_9_0_UP_OR_STD>
<NET_3_1_LESS_OR_STD Condition="'$(NET_3_1_LESS)' == true Or '$(NET_STD_2_X)' == true">True</NET_3_1_LESS_OR_STD>
<NET_3_1_UP_OR_STD Condition="'$(NET_3_1_UP)' == true Or '$(NET_STD_2_X)' == true">True</NET_3_1_UP_OR_STD>
<NET_5_0_LESS_OR_STD Condition="'$(NET_5_0_LESS)' == true Or '$(NET_STD_2_X)' == true">True</NET_5_0_LESS_OR_STD>
<NET_5_0_UP_OR_STD Condition="'$(NET_5_0_UP)' == true Or '$(NET_STD_2_X)' == true">True</NET_5_0_UP_OR_STD>
<NET_6_0_LESS_OR_STD Condition="'$(NET_6_0_LESS)' == true Or '$(NET_STD_2_X)' == true">True</NET_6_0_LESS_OR_STD>
<NET_6_0_UP_OR_STD Condition="'$(NET_6_0_UP)' == true Or '$(NET_STD_2_X)' == true">True</NET_6_0_UP_OR_STD>
<NET_7_0_LESS_OR_STD Condition="'$(NET_7_0_LESS)' == true Or '$(NET_STD_2_X)' == true">True</NET_7_0_LESS_OR_STD>
<NET_7_0_UP_OR_STD Condition="'$(NET_7_0_UP)' == true Or '$(NET_STD_2_X)' == true">True</NET_7_0_UP_OR_STD>
<NET_8_0_LESS_OR_STD Condition="'$(NET_8_0_LESS)' == true Or '$(NET_STD_2_X)' == true">True</NET_8_0_LESS_OR_STD>
<NET_8_0_UP_OR_STD Condition="'$(NET_8_0_UP)' == true Or '$(NET_STD_2_X)' == true">True</NET_8_0_UP_OR_STD>
<NET_9_0_LESS_OR_STD Condition="'$(NET_9_0_LESS)' == true Or '$(NET_STD_2_X)' == true">True</NET_9_0_LESS_OR_STD>
<NET_9_0_UP_OR_STD Condition="'$(NET_9_0_UP)' == true Or '$(NET_STD_2_X)' == true">True</NET_9_0_UP_OR_STD>

</PropertyGroup>

Expand Down
3 changes: 1 addition & 2 deletions Directory.Build.override.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project>

<ItemGroup Condition="'$(NET_6_0)' == true Or '$(NET_7_0)' == true">
<PackageReference Update="Serilog.AspNetCore" Version="7.*" />
<ItemGroup>
</ItemGroup>

</Project>
27 changes: 17 additions & 10 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<Import Project="$(MSBuildThisFileDirectory)Directory.Build.initial.targets" Condition="Exists('$(MSBuildThisFileDirectory)Directory.Build.initial.targets')" />

<PropertyGroup Condition="'$(LatestDevFrameworkVersion)' == ''">
<LatestDevFrameworkVersion>9.*-*</LatestDevFrameworkVersion>
<LatestDevFrameworkVersion>10.*-*</LatestDevFrameworkVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(FrameworkVersion)' == ''">
<FrameworkVersion Condition="'$(NET_3_1)' == true">3.*</FrameworkVersion>
<FrameworkVersion Condition="'$(NET_5_0)' == true">5.*</FrameworkVersion>
<FrameworkVersion Condition="'$(NET_6_0_UP_OR_STD)' == true">8.*</FrameworkVersion>
<FrameworkVersion Condition="'$(NET_5_0_LESS)' == true">7.*</FrameworkVersion>
<FrameworkVersion Condition="'$(NET_6_0)' == true Or '$(NET_7_0)' == true Or '$(NET_8_0)' == true Or '$(NET_STD_2_X)' == true">8.*</FrameworkVersion>
<FrameworkVersion Condition="'$(NET_9_0_UP)' == true">9.*-*</FrameworkVersion>
<FrameworkVersion Condition="'$(FrameworkVersion)' == ''">$(LatestDevFrameworkVersion)</FrameworkVersion>
</PropertyGroup>

Expand All @@ -21,20 +21,26 @@
<AspNetFrameworkVersion Condition="'$(NET_6_0)' == true">6.*</AspNetFrameworkVersion>
<AspNetFrameworkVersion Condition="'$(NET_7_0)' == true">7.*</AspNetFrameworkVersion>
<AspNetFrameworkVersion Condition="'$(NET_8_0)' == true">8.*</AspNetFrameworkVersion>
<AspNetFrameworkVersion Condition="'$(NET_9_0)' == true">9.*-*</AspNetFrameworkVersion>
<AspNetFrameworkVersion Condition="'$(AspNetFrameworkVersion)' == ''">$(LatestDevFrameworkVersion)</AspNetFrameworkVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(EFCoreFrameworkVersion)' == ''">
<EFCoreFrameworkVersion Condition="'$(NET_5_0_LESS_OR_STD)' == true">5.*</EFCoreFrameworkVersion>
<EFCoreFrameworkVersion Condition="'$(NET_6_0)' == true Or '$(NET_7_0)' == true">7.*</EFCoreFrameworkVersion>
<EFCoreFrameworkVersion Condition="'$(NET_8_0)' == true">8.*</EFCoreFrameworkVersion>
<EFCoreFrameworkVersion Condition="'$(NET_9_0)' == true">9.*-*</EFCoreFrameworkVersion>
<EFCoreFrameworkVersion Condition="'$(EFCoreFrameworkVersion)' == ''">$(LatestDevFrameworkVersion)</EFCoreFrameworkVersion>
</PropertyGroup>

<PropertyGroup>
<NpgsqlVersion Condition="'$(NpgsqlVersion)' == '' And '$(NET_3_1_LESS_OR_STD)' == true">4.*</NpgsqlVersion>
<NpgsqlVersion Condition="'$(NpgsqlVersion)' == '' And '$(NET_9_0_UP)' == true">8.*</NpgsqlVersion>
<NpgsqlVersion Condition="'$(NpgsqlVersion)' == ''">$(EFCoreFrameworkVersion)</NpgsqlVersion>
<SystemTextJsonVersion Condition="'$(SystemTextJsonVersion)' == '' And '$(NET_5_0_LESS)' == true">8.*</SystemTextJsonVersion>
<SystemTextJsonVersion Condition="'$(SystemTextJsonVersion)' == ''">$(FrameworkVersion)</SystemTextJsonVersion>
<SwashbuckleVersion Condition="'$(SwashbuckleVersion)' == '' And '$(NET_5_0_LESS)' == true">6.3.*</SwashbuckleVersion>
<!-- [email protected] reference to [email protected] by mistake -->
<SwashbuckleVersion Condition="'$(SwashbuckleVersion)' == '' And '$(NET_5_0_LESS)' == true">6.3.1</SwashbuckleVersion>
<SwashbuckleVersion Condition="'$(SwashbuckleVersion)' == '' And '$(NET_6_0)' == true">6.4.*</SwashbuckleVersion>
<SwashbuckleVersion Condition="'$(SwashbuckleVersion)' == ''">6.*</SwashbuckleVersion>
</PropertyGroup>
Expand Down Expand Up @@ -86,8 +92,8 @@
<PackageReference Update="Serilog.Sinks.Console" Version="5.*" />
<PackageReference Update="Serilog.Sinks.Debug" Version="2.*" />
<PackageReference Update="Serilog.Sinks.File" Version="5.*" />
<PackageReference Update="Serilog.Sinks.PeriodicBatching" Version="3.*" />
<PackageReference Update="Serilog.Sinks.Seq" Version="6.*" />
<PackageReference Update="Serilog.Sinks.PeriodicBatching" Version="4.*" />
<PackageReference Update="Serilog.Sinks.Seq" Version="7.*" />

<!--misc-->
<PackageReference Update="AutoMapper" Version="12.*" />
Expand Down Expand Up @@ -271,8 +277,9 @@
<PackageReference Update="Microsoft.EntityFrameworkCore.SqlServer" Version="$(EFCoreFrameworkVersion)" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Tools" Version="$(EFCoreFrameworkVersion)" PrivateAssets="All" />
<PackageReference Update="Microsoft.SqlServer.Server" Version="1.*" />
<PackageReference Update="Npgsql" Version="$(EFCoreFrameworkVersion)" />
<PackageReference Update="Npgsql" Version="8.*" Condition="'$(NET_6_0)' == true Or '$(NET_7_0)' == true" />

<!-- EFCore.PG and Npgsql must same version https://github.com/npgsql/efcore.pg/issues/3011 -->
<PackageReference Update="Npgsql" Version="$(NpgsqlVersion)" />
<PackageReference Update="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(EFCoreFrameworkVersion)" />
<PackageReference Update="EFCore.NamingConventions" Version="$(EFCoreFrameworkVersion)" />

Expand Down Expand Up @@ -387,7 +394,7 @@

</ItemGroup>

<ItemGroup Condition="'$(NET_5_0_LESS)' == true">
<ItemGroup Condition="'$(NET_5_0_LESS_OR_STD)' == true">
<PackageReference Update="Serilog" Version="3.0.*" />
<PackageReference Update="Serilog.AspNetCore" Version="7.*" />
<PackageReference Update="Serilog.Extensions.Hosting" Version="7.*" />
Expand Down
8 changes: 4 additions & 4 deletions EchoServiceApi/EchoServiceApi.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
<UserSecretsId>netlah-echoserviceapi-bf38</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
Expand All @@ -13,7 +13,7 @@
<None Remove="Logs\**" />
</ItemGroup>

<ItemGroup Condition="'$(NET_6_0)' == 'true'">
<ItemGroup Condition="'$(NET_6_0)' == true">
<PackageReference Include="Azure.Core.Amqp" />
<PackageReference Include="Azure.Core" />
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Blobs" />
Expand Down Expand Up @@ -100,7 +100,7 @@
<PackageReference Include="System.Windows.Extensions" />
</ItemGroup>

<ItemGroup Condition="'$(NET_7_0)' == 'true'">
<ItemGroup Condition="'$(NET_7_0)' == true">
<PackageReference Include="Azure.Core.Amqp" />
<PackageReference Include="Azure.Core" />
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Blobs" />
Expand Down Expand Up @@ -162,7 +162,7 @@
<PackageReference Include="System.Windows.Extensions" />
</ItemGroup>

<ItemGroup Condition="'$(NET_8_0)' == 'true'">
<ItemGroup Condition="'$(NET_8_0)' == true Or '$(NET_9_0)' == true">
<PackageReference Include="Azure.Core.Amqp" />
<PackageReference Include="Azure.Core" />
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Blobs" />
Expand Down

0 comments on commit 6cc6999

Please sign in to comment.