Merge pull request #21877 from brandonh6k/main

Update dotnet to .NET 8.0 (LTS)
This commit is contained in:
Brandon Hunt 2025-01-27 03:33:29 -07:00 committed by GitHub
parent 5df76d0d6c
commit e536caae57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 13 deletions

View File

@ -60,7 +60,7 @@ Let's get started!
? What application platform does your project use? ASP.NET Core ? What application platform does your project use? ASP.NET Core
? What's the name of your solution's main project? myWebApp ? What's the name of your solution's main project? myWebApp
? What version of .NET do you want to use? 6.0 ? What version of .NET do you want to use? 8.0
? What local port do you want to use to access your server? 8080 ? What local port do you want to use to access your server? 8080
``` ```

View File

@ -307,19 +307,19 @@ The following is the updated Dockerfile.
```Dockerfile {hl_lines="10-13"} ```Dockerfile {hl_lines="10-13"}
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
ARG TARGETARCH ARG TARGETARCH
COPY . /source COPY . /source
WORKDIR /source/src WORKDIR /source/src
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet publish -a ${TARGETARCH/amd64/x64} --use-current-runtime --self-contained false -o /app dotnet publish -a ${TARGETARCH/amd64/x64} --use-current-runtime --self-contained false -o /app
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS development FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS development
COPY . /source COPY . /source
WORKDIR /source/src WORKDIR /source/src
CMD dotnet run --no-launch-profile CMD dotnet run --no-launch-profile
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS final FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final
WORKDIR /app WORKDIR /app
COPY --from=build /app . COPY --from=build /app .
ARG UID=10001 ARG UID=10001
@ -380,7 +380,7 @@ secrets:
file: db/password.txt file: db/password.txt
``` ```
Your containerized application will now use the `mcr.microsoft.com/dotnet/sdk:6.0-alpine` image, which includes development tools like `dotnet test`. Continue to the next section to learn how you can run `dotnet test`. Your containerized application will now use the `mcr.microsoft.com/dotnet/sdk:8.0-alpine` image, which includes development tools like `dotnet test`. Continue to the next section to learn how you can run `dotnet test`.
## Summary ## Summary

View File

@ -36,7 +36,7 @@ You should see output that contains the following.
Starting test execution, please wait... Starting test execution, please wait...
A total of 1 test files matched the specified pattern. A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: < 1 ms - /source/tests/bin/Debug/net6.0/tests.dll (net6.0) Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: < 1 ms - /source/tests/bin/Debug/net8.0/tests.dll (net8.0)
``` ```
To learn more about the command, see [docker compose run](/reference/cli/docker/compose/run/). To learn more about the command, see [docker compose run](/reference/cli/docker/compose/run/).
@ -50,7 +50,7 @@ The following is the updated Dockerfile.
```dockerfile {hl_lines="9"} ```dockerfile {hl_lines="9"}
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
ARG TARGETARCH ARG TARGETARCH
COPY . /source COPY . /source
WORKDIR /source/src WORKDIR /source/src
@ -58,12 +58,12 @@ RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet publish -a ${TARGETARCH/amd64/x64} --use-current-runtime --self-contained false -o /app dotnet publish -a ${TARGETARCH/amd64/x64} --use-current-runtime --self-contained false -o /app
RUN dotnet test /source/tests RUN dotnet test /source/tests
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS development FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS development
COPY . /source COPY . /source
WORKDIR /source/src WORKDIR /source/src
CMD dotnet run --no-launch-profile CMD dotnet run --no-launch-profile
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS final FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final
WORKDIR /app WORKDIR /app
COPY --from=build /app . COPY --from=build /app .
ARG UID=10001 ARG UID=10001
@ -92,16 +92,16 @@ You should see output containing the following.
#11 1.564 Determining projects to restore... #11 1.564 Determining projects to restore...
#11 3.421 Restored /source/src/myWebApp.csproj (in 1.02 sec). #11 3.421 Restored /source/src/myWebApp.csproj (in 1.02 sec).
#11 19.42 Restored /source/tests/tests.csproj (in 17.05 sec). #11 19.42 Restored /source/tests/tests.csproj (in 17.05 sec).
#11 27.91 myWebApp -> /source/src/bin/Debug/net6.0/myWebApp.dll #11 27.91 myWebApp -> /source/src/bin/Debug/net8.0/myWebApp.dll
#11 28.47 tests -> /source/tests/bin/Debug/net6.0/tests.dll #11 28.47 tests -> /source/tests/bin/Debug/net8.0/tests.dll
#11 28.49 Test run for /source/tests/bin/Debug/net6.0/tests.dll (.NETCoreApp,Version=v6.0) #11 28.49 Test run for /source/tests/bin/Debug/net8.0/tests.dll (.NETCoreApp,Version=v8.0)
#11 28.67 Microsoft (R) Test Execution Command Line Tool Version 17.3.3 (x64) #11 28.67 Microsoft (R) Test Execution Command Line Tool Version 17.3.3 (x64)
#11 28.67 Copyright (c) Microsoft Corporation. All rights reserved. #11 28.67 Copyright (c) Microsoft Corporation. All rights reserved.
#11 28.68 #11 28.68
#11 28.97 Starting test execution, please wait... #11 28.97 Starting test execution, please wait...
#11 29.03 A total of 1 test files matched the specified pattern. #11 29.03 A total of 1 test files matched the specified pattern.
#11 32.07 #11 32.07
#11 32.08 Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: < 1 ms - /source/tests/bin/Debug/net6.0/tests.dll (net6.0) #11 32.08 Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: < 1 ms - /source/tests/bin/Debug/net8.0/tests.dll (net8.0)
#11 DONE 32.2s #11 DONE 32.2s
``` ```