From fdb1c34d61ff3e9fc56573cba6facb8d7007de78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Michel?= Date: Tue, 20 Dec 2022 19:20:50 +0100 Subject: [PATCH] Feature/dotnet7 migration (#828) * migration to .net 7 * remove temp memory database * adapt global.json .net 7 * adapt Rich Code Navigation to .net 7 * update and clean run for .net 7 * update .net ef tool Co-authored-by: cedri --- .devcontainer/Dockerfile | 2 +- .github/workflows/dotnetcore.yml | 2 +- .github/workflows/richnav.yml | 2 +- .vscode/launch.json | 2 +- Directory.Packages.props | 66 +++++++++++++++++++ README.md | 2 +- eShopOnWeb.sln | 3 +- global.json | 2 +- src/ApplicationCore/ApplicationCore.csproj | 15 ++--- src/BlazorAdmin/BlazorAdmin.csproj | 25 +++---- src/BlazorShared/BlazorShared.csproj | 7 +- src/Infrastructure/Infrastructure.csproj | 13 ++-- src/PublicApi/Dockerfile | 4 +- src/PublicApi/Properties/launchSettings.json | 35 +++++++--- src/PublicApi/PublicApi.csproj | 39 ++++++----- src/Web/.config/dotnet-tools.json | 2 +- src/Web/Dockerfile | 4 +- src/Web/Web.csproj | 39 ++++++----- tests/FunctionalTests/FunctionalTests.csproj | 18 ++--- .../IntegrationTests/IntegrationTests.csproj | 13 ++-- .../PublicApiIntegrationTests.csproj | 16 +++-- tests/UnitTests/UnitTests.csproj | 21 ++---- 22 files changed, 198 insertions(+), 134 deletions(-) create mode 100644 Directory.Packages.props diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d188b1d..e69dc7b 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. #------------------------------------------------------------------------------------------------------------- -FROM mcr.microsoft.com/dotnet/sdk:5.0 +FROM mcr.microsoft.com/dotnet/sdk:7.0 # This Dockerfile adds a non-root user with sudo access. Use the "remoteUser" # property in devcontainer.json to use it. On Linux, the container user's GID/UIDs diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 4fcc6d4..d5b7ee8 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '7.0.x' include-prerelease: true - name: Build with dotnet diff --git a/.github/workflows/richnav.yml b/.github/workflows/richnav.yml index c21c216..977ee7c 100644 --- a/.github/workflows/richnav.yml +++ b/.github/workflows/richnav.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.1.x + dotnet-version: 7.0.x - name: Build with dotnet run: dotnet build ./eShopOnWeb.sln --configuration Release diff --git a/.vscode/launch.json b/.vscode/launch.json index d375cae..d6ed320 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/Web/bin/Debug/net5.0/Web.dll", + "program": "${workspaceFolder}/src/Web/bin/Debug/net7.0/Web.dll", "args": [], "cwd": "${workspaceFolder}/src/Web", "stopAtEntry": false, diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..648bafb --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,66 @@ + + + true + net7.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + all + runtime; build; native; contentfiles; analyzers + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index d10d35b..10c4238 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The **eShopOnWeb** sample is related to the [eShopOnContainers](https://github.c The goal for this sample is to demonstrate some of the principles and patterns described in the [eBook](https://aka.ms/webappebook). It is not meant to be an eCommerce reference application, and as such it does not implement many features that would be obvious and/or essential to a real eCommerce application. > ### VERSIONS -> #### The `main` branch is currently running ASP.NET Core 6.0. +> #### The `main` branch is currently running ASP.NET Core 7.0. > #### Older versions are tagged. ## Topics (eBook TOC) diff --git a/eShopOnWeb.sln b/eShopOnWeb.sln index 2adaaf8..e878f9a 100755 --- a/eShopOnWeb.sln +++ b/eShopOnWeb.sln @@ -24,6 +24,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0BD72BEA-EF42-4B72-8B69-12A39EC76FBA}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig + Directory.Packages.props = Directory.Packages.props docker-compose.override.yml = docker-compose.override.yml docker-compose.yml = docker-compose.yml .github\workflows\dotnetcore.yml = .github\workflows\dotnetcore.yml @@ -38,7 +39,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorAdmin", "src\BlazorAd EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorShared", "src\BlazorShared\BlazorShared.csproj", "{715CF7AF-A1EE-40A6-94A0-8DA3F3B2CAE9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PublicApiIntegrationTests", "tests\PublicApiIntegrationTests\PublicApiIntegrationTests.csproj", "{D53EF010-8F8C-4337-A059-456E19D8AE63}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PublicApiIntegrationTests", "tests\PublicApiIntegrationTests\PublicApiIntegrationTests.csproj", "{D53EF010-8F8C-4337-A059-456E19D8AE63}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/global.json b/global.json index 957199c..8ec4b2b 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.x", + "version": "7.0.x", "rollForward": "latestFeature" } } diff --git a/src/ApplicationCore/ApplicationCore.csproj b/src/ApplicationCore/ApplicationCore.csproj index 2d2c5cd..1e7e77b 100644 --- a/src/ApplicationCore/ApplicationCore.csproj +++ b/src/ApplicationCore/ApplicationCore.csproj @@ -1,18 +1,17 @@  - - net6.0 + Microsoft.eShopWeb.ApplicationCore enable - - - - - - + + + + + + diff --git a/src/BlazorAdmin/BlazorAdmin.csproj b/src/BlazorAdmin/BlazorAdmin.csproj index 5eb9251..393b330 100644 --- a/src/BlazorAdmin/BlazorAdmin.csproj +++ b/src/BlazorAdmin/BlazorAdmin.csproj @@ -1,19 +1,14 @@ - - - - net6.0 - - + - - - - - - - - - + + + + + + + + + diff --git a/src/BlazorShared/BlazorShared.csproj b/src/BlazorShared/BlazorShared.csproj index c0aa99c..8cd1e29 100644 --- a/src/BlazorShared/BlazorShared.csproj +++ b/src/BlazorShared/BlazorShared.csproj @@ -1,14 +1,13 @@  - - net6.0 + BlazorShared BlazorShared - - + + diff --git a/src/Infrastructure/Infrastructure.csproj b/src/Infrastructure/Infrastructure.csproj index a0be8bb..026a8ca 100644 --- a/src/Infrastructure/Infrastructure.csproj +++ b/src/Infrastructure/Infrastructure.csproj @@ -1,17 +1,16 @@  - - net6.0 + Microsoft.eShopWeb.Infrastructure enable - - - - - + + + + + diff --git a/src/PublicApi/Dockerfile b/src/PublicApi/Dockerfile index f768db5..885a155 100644 --- a/src/PublicApi/Dockerfile +++ b/src/PublicApi/Dockerfile @@ -1,11 +1,11 @@ #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:6.0 AS base +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base WORKDIR /app EXPOSE 80 EXPOSE 443 -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build WORKDIR /app COPY . . #COPY ["src/PublicApi/PublicApi.csproj", "./PublicApi/"] diff --git a/src/PublicApi/Properties/launchSettings.json b/src/PublicApi/Properties/launchSettings.json index fbed524..c44d516 100644 --- a/src/PublicApi/Properties/launchSettings.json +++ b/src/PublicApi/Properties/launchSettings.json @@ -1,13 +1,4 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:52023", - "sslPort": 44339 - } - }, - "$schema": "http://json.schemastore.org/launchsettings.json", "profiles": { "IIS Express": { "commandName": "IISExpress", @@ -25,6 +16,32 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "https://localhost:5099;http://localhost:5098" + }, + "WSL": { + "commandName": "WSL2", + "launchBrowser": true, + "launchUrl": "https://localhost:5099/swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "https://localhost:5099;http://localhost:5098" + }, + "distributionName": "" + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", + "publishAllPorts": true, + "useSSL": true + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:52023", + "sslPort": 44339 } } } \ No newline at end of file diff --git a/src/PublicApi/PublicApi.csproj b/src/PublicApi/PublicApi.csproj index 4677879..a7d195c 100644 --- a/src/PublicApi/PublicApi.csproj +++ b/src/PublicApi/PublicApi.csproj @@ -1,7 +1,6 @@  - - net6.0 + Microsoft.eShopWeb.PublicApi 5b662463-1efd-4bae-bde4-befe0be3e8ff Linux @@ -10,28 +9,28 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + diff --git a/src/Web/.config/dotnet-tools.json b/src/Web/.config/dotnet-tools.json index 5060fd6..43a4368 100644 --- a/src/Web/.config/dotnet-tools.json +++ b/src/Web/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-ef": { - "version": "6.0.4", + "version": "7.0.1", "commands": [ "dotnet-ef" ] diff --git a/src/Web/Dockerfile b/src/Web/Dockerfile index 9062398..9a5e23d 100644 --- a/src/Web/Dockerfile +++ b/src/Web/Dockerfile @@ -7,7 +7,7 @@ # # RUN COMMAND # docker run --name eshopweb --rm -it -p 5106:5106 web -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build WORKDIR /app COPY *.sln . @@ -17,7 +17,7 @@ RUN dotnet restore RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS runtime WORKDIR /app COPY --from=build /app/src/Web/out ./ diff --git a/src/Web/Web.csproj b/src/Web/Web.csproj index 1d06eb0..5e2f3ee 100644 --- a/src/Web/Web.csproj +++ b/src/Web/Web.csproj @@ -1,7 +1,6 @@  - - net6.0 + enable enable Microsoft.eShopWeb.Web @@ -14,26 +13,26 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/tests/FunctionalTests/FunctionalTests.csproj b/tests/FunctionalTests/FunctionalTests.csproj index ba3f67d..f484cf9 100644 --- a/tests/FunctionalTests/FunctionalTests.csproj +++ b/tests/FunctionalTests/FunctionalTests.csproj @@ -1,7 +1,6 @@  - - net6.0 + Microsoft.eShopWeb.FunctionalTests false enable @@ -15,15 +14,12 @@ - - - - - all - runtime; build; native; contentfiles; analyzers - - - + + + + + + diff --git a/tests/IntegrationTests/IntegrationTests.csproj b/tests/IntegrationTests/IntegrationTests.csproj index 7473d83..5876dc3 100644 --- a/tests/IntegrationTests/IntegrationTests.csproj +++ b/tests/IntegrationTests/IntegrationTests.csproj @@ -1,17 +1,16 @@  - - net6.0 + Microsoft.eShopWeb.IntegrationTests false - - - - - + + + + + all runtime; build; native; contentfiles; analyzers diff --git a/tests/PublicApiIntegrationTests/PublicApiIntegrationTests.csproj b/tests/PublicApiIntegrationTests/PublicApiIntegrationTests.csproj index d560cac..467bc1f 100644 --- a/tests/PublicApiIntegrationTests/PublicApiIntegrationTests.csproj +++ b/tests/PublicApiIntegrationTests/PublicApiIntegrationTests.csproj @@ -1,7 +1,6 @@ - - net6.0 + enable false @@ -20,11 +19,14 @@ - - - - - + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/tests/UnitTests/UnitTests.csproj b/tests/UnitTests/UnitTests.csproj index 7381753..f8bbe01 100644 --- a/tests/UnitTests/UnitTests.csproj +++ b/tests/UnitTests/UnitTests.csproj @@ -1,7 +1,6 @@  - - net6.0 + enable Microsoft.eShopWeb.UnitTests false @@ -10,18 +9,12 @@ - - - - - - all - runtime; build; native; contentfiles; analyzers - - - all - runtime; build; native; contentfiles; analyzers - + + + + + +