Skip to content

Commit

Permalink
.Net 8.0 (#6)
Browse files Browse the repository at this point in the history
* Consolidate Directory.Build.targets

* Support .NET 8.0 and 7.0

* Build branch dev

* Fix publish

* Update minver-cli@4.3.0

* Fix build warning

* Update README

* Consolidate dependency

* Update docker .NET 8.0

* Windows support .NET 7.0 and .NET 8.0

* Fix Shell SIGTERM with exec

* Typo

* Update dependency
  • Loading branch information
thohng authored Oct 20, 2023
1 parent 1471dcf commit cf23180
Show file tree
Hide file tree
Showing 23 changed files with 556 additions and 128 deletions.
17 changes: 16 additions & 1 deletion .azure/pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ trigger:
branches:
include:
- main
- dev*
tags:
include:
- "*.*.*"
Expand All @@ -26,6 +27,17 @@ pool:
vmImage: $(imageName)

steps:
- task: UseDotNet@2
displayName: "Use .NET Core sdk 8.x"
inputs:
version: 8.x
includePreviewVersions: true

- task: UseDotNet@2
displayName: "Use .NET Core sdk 7.x"
inputs:
version: 7.x

- task: UseDotNet@2
displayName: "Use .NET Core sdk 6.x"
inputs:
Expand All @@ -37,5 +49,8 @@ steps:
- script: dotnet build --configuration $(buildConfiguration)
displayName: "dotnet build $(buildConfiguration)"

- script: dotnet publish EchoServiceApi -o ./artifacts/echoServiceApi/ --configuration $(buildConfiguration) --no-build
- script: |
dotnet publish EchoServiceApi --configuration $(buildConfiguration) --no-build -f net6.0 --no-build -o artifacts/net6.0/app
dotnet publish EchoServiceApi --configuration $(buildConfiguration) --no-build -f net7.0 --no-build -o artifacts/net7.0/app
dotnet publish EchoServiceApi --configuration $(buildConfiguration) --no-build -f net8.0 --no-build -o artifacts/net8.0/app
displayName: "dotnet publish $(buildConfiguration)"
8 changes: 3 additions & 5 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
"isRoot": true,
"tools": {
"minver-cli": {
"version": "4.2.0",
"commands": [
"minver"
]
"version": "4.3.0",
"commands": ["minver"]
}
}
}
}
7 changes: 2 additions & 5 deletions .docker-linux/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#ARG ASPNET_IMAGE_TAG=6.0-alpine
#ARG ASPNET_IMAGE=mcr.microsoft.com/dotnet/aspnet:${ASPNET_IMAGE_TAG}
ARG ASPNET_IMAGE_TAG=latest
ARG ASPNET_IMAGE_TAG=6.0-alpine
ARG ASPNET_IMAGE=netlah/aspnet-webssh:${ASPNET_IMAGE_TAG}
FROM ${ASPNET_IMAGE}
WORKDIR /app
EXPOSE 80
RUN apk update && apk add --no-cache ca-certificates
COPY app .
ENTRYPOINT ["/opt/startup/init_container.sh"]
CMD ["dotnet", "EchoServiceApi.dll"]
ENTRYPOINT ["/opt/startup/init_container.sh", "exec", "dotnet", "EchoServiceApi.dll"]
3 changes: 2 additions & 1 deletion .docker-windows/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ARG ASPNET_IMAGE=mcr.microsoft.com/dotnet/aspnet:6.0-nanoserver-1809
ARG ASPNET_IMAGE_TAG=6.0-nanoserver-1809
ARG ASPNET_IMAGE=mcr.microsoft.com/dotnet/aspnet:${ASPNET_IMAGE_TAG}
FROM ${ASPNET_IMAGE}
WORKDIR /app
EXPOSE 80
Expand Down
71 changes: 68 additions & 3 deletions .github/workflows/aspnet-core.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ASP.NETCore 6
name: ASP.NET Core

on:
push:
Expand All @@ -20,11 +20,13 @@ jobs:
with:
fetch-depth: 0

- name: Setup .NET Core 6.x
- name: Setup .NET Core 8.0.x, 7.0.x, and 6.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x-x
- name: dotnet info
run: dotnet --info
Expand Down Expand Up @@ -71,6 +73,50 @@ jobs:
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=570,prefix=6.0-,pattern=^(\d+\.\d+)(\.\d+)?(-.+)?$,group=1
type=match,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=560,prefix=6.0-,pattern=^(\d+)\.\d+(\.\d+)?(-.+)?$,group=1
- name: Docker meta 7.0
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }}
id: meta70
uses: docker/metadata-action@v4
with:
images: |
${{ secrets.DOCKER_HUB_REPOS }}
netlah/echo-service-api,enable=${{ startsWith(github.ref, 'refs/tags/') }}
flavor: |
latest=auto
suffix=${{ env.TAG_SUFFIX }}
prefix=7.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=7.0-pr-
type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=7.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=580,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: Docker meta 8.0
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }}
id: meta80
uses: docker/metadata-action@v4
with:
images: |
${{ secrets.DOCKER_HUB_REPOS }}
netlah/echo-service-api,enable=${{ startsWith(github.ref, 'refs/tags/') }}
flavor: |
latest=auto
suffix=${{ env.TAG_SUFFIX }}
prefix=8.0-preview-
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=8.0-preview-pr-
type=sha,enable=${{ github.event_name != 'pull_request' }},priority=400,prefix=8.0-preview-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=580,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 @@ -81,13 +127,18 @@ jobs:
run: dotnet test -c Release --no-build --verbosity normal

- name: Publish
run: dotnet publish EchoServiceApi -c Release --no-build -o artifacts/net6.0/app
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
- 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
- name: Enabling Docker Daemon With experimental features
if: ${{ success() && runner.os == 'Linux' }}
Expand All @@ -114,3 +165,17 @@ jobs:
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }}
shell: pwsh
run: ./docker-build.ps1 -Context ./artifacts/net6.0 -Squash -Tags "${{ steps.meta60.outputs.tags }}" -Labels "${{ steps.meta60.outputs.labels }}"

- name: Build and Push 7.0
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }}
shell: pwsh
run: |
$aspnetImageTag70 = if ($Env:RUNNER_OS -eq 'Linux') { '7.0-alpine' } else { '7.0-nanoserver-1809' }
./docker-build.ps1 -Context ./artifacts/net7.0 -Squash -Tags "${{ steps.meta70.outputs.tags }}" -Labels "${{ steps.meta70.outputs.labels }}" -BuildArgs "ASPNET_IMAGE_TAG=$aspnetImageTag70"
- name: Build and Push 8.0
if: ${{ success() && (runner.os == 'Linux' || runner.os == 'Windows') }}
shell: pwsh
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"
34 changes: 34 additions & 0 deletions Common.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project>

<PropertyGroup>
<CurrentFrameworkVersion>6.0.23;7.0.12;8.0.0-rc.2</CurrentFrameworkVersion>
<ImportedCommonProps>True</ImportedCommonProps>

<NET_ID>$([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework)))</NET_ID>
<NET_VER>$([MSBuild]::GetTargetFrameworkVersion($(TargetFramework)))</NET_VER>

<NET_STD_2_0>False</NET_STD_2_0>
<NET_STD_2_1>False</NET_STD_2_1>
<NET_3_1>False</NET_3_1>
<NET_5_0>False</NET_5_0>
<NET_5_0>False</NET_5_0>
<NET_6_0>False</NET_6_0>
<NET_7_0>False</NET_7_0>
<NET_8_0>False</NET_8_0>

<NET_STD_2_0 Condition="'$(NET_VER)' == '2.0' And '$(NET_ID)' == '.NETStandard'">True</NET_STD_2_0>
<NET_STD_2_1 Condition="'$(NET_VER)' == '2.1' And '$(NET_ID)' == '.NETStandard'">True</NET_STD_2_1>
<NET_3_1 Condition="'$(NET_VER)' == '3.1' And '$(NET_ID)' == '.NETCoreApp'">True</NET_3_1>
<NET_5_0 Condition="'$(NET_VER)' == '5.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_5_0>
<NET_6_0 Condition="'$(NET_VER)' == '6.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_6_0>
<NET_7_0 Condition="'$(NET_VER)' == '7.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_7_0>
<NET_8_0 Condition="'$(NET_VER)' == '8.0' And '$(NET_ID)' == '.NETCoreApp'">True</NET_8_0>

<NET_3_1_OR_LESS>False</NET_3_1_OR_LESS>
<NET_5_1_OR_LESS>False</NET_5_1_OR_LESS>
<NET_3_1_OR_LESS Condition="'$(NET_VER)' &lt;= '3.1' And ('$(NET_ID)' == '.NETCoreApp' Or '$(NET_ID)' == '.NETStandard')">True</NET_3_1_OR_LESS>
<NET_5_1_OR_LESS Condition="'$(NET_VER)' &lt;= '5.0' And ('$(NET_ID)' == '.NETCoreApp' Or '$(NET_ID)' == '.NETStandard')">True</NET_5_1_OR_LESS>

</PropertyGroup>

</Project>
Loading

0 comments on commit cf23180

Please sign in to comment.