天天看點

ABP Framework 手動更新指南:從6.0.1更新到7.0.0

作者:DotNET技術圈

ABP

7.0.0

正式版已經釋出,ABP-Framework-All-In-One 項目同步更新。

LeptonX Lite Theme 目前還沒有包含在源碼解決方案中,還是以 Nuget 包提供,目前已經更新到

2.0.0

ABP

7.0.0

最大的變化是提供 OpenIddict 應用子產品,用于替換 IdentityServer 應用子產品。IdentityServer 功能強大,經過多個版本疊代,在 ABP Framework 中也足夠穩定,隻要官方繼續維護該應用子產品,可以不用着急切換到 OpenIddcit 。

本文記錄從

6.0.1

更新到

7.0.0

的詳細過程及注意事項。

第一步:更新 ABP Framework 源碼

下載下傳最新版 ABP Framework 源碼

7.0.0

到解決方案根目錄,将原

abp

目錄打包備份,删除該目錄,然後将

abp-7.0.0

并解壓重命名為

abp

,實作架構源碼更新到最新。

第二步:更新 .NET 版本

該版本是跟随 .NET 7 釋出之後的更新版,是以 .NET 需要更新到 7 。如果是 Dcoker 部署,需要更新鏡像中采用的 SDK 版本。

檢視已安裝的 .NET 版本,在終端執行指令

dotnet --list-sdks

6.0.400 [/usr/local/share/dotnet/sdk]
7.0.100 [/usr/local/share/dotnet/sdk]           

修改解決方案中

global.json

檔案

{
"sdk": {
"version": "7.0.100"
 }
}           

更新項目目标架構

項目目标架構

TargetFramework

如果為

netstandard2.0

,不需要更新目标架構,與 .NET 7 相容。

目标架構為

net6.0

,都必須更新到

net7.0

找到應用程式項目檔案

.csproj

修改:

- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>           

src

目錄中包含 11 個項目,

test

目錄中包含 5 個項目,逐一檢查修改。

更新程式集版本

解決方案中還有部分項目(

src

test

目錄中的項目)中的程式集直接基于 Nuget 包引用,所引用的程式集版本應該與 ABP Framework源碼項目(

abp

目錄中的項目)保持版本一緻。

src

目錄項目程式集版本更新清單:

  • • Serilog.AspNetCore

    4.1.0

    ->

    5.0.0

  • • Serilog.Sinks.Async

    1.4.0

    ->

    1.5.0

  • • Microsoft.AspNetCore.Authentication.JwtBearer

    5.0.*

    ->

    7.0.0

  • • Microsoft.AspNetCore.DataProtection.StackExchangeRedis

    5.0.*

    ->

    7.0.0

  • • Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite

    1.0.0-beta.3

    ->

    2.0.0-*

  • • Microsoft.EntityFrameworkCore.Tools

    5.0.12

    ->

    7.0.1

  • • Microsoft.Extensions.FileProviders.Embedded

    6.0.5

    ->

    7.0.0

  • • Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite

    1.0.0-beta.3

    ->

    2.0.0

  • • Serilog.Extensions.Logging

    3.0.1

    ->

    3.1.0

  • • Serilog.Sinks.Async

    1.4.0

    ->

    1.5.0

  • • Serilog.Sinks.File

    4.1.0

    ->

    5.0.0

  • • Serilog.Sinks.Console

    3.1.1

    ->

    4.1.0

test

目錄測試項目程式集版本更新類表:

  • • Microsoft.NET.Test.Sdk

    16.9.1

    ->

    17.2.0

  • • Microsoft.Extensions.Hosting

    5.0.*

    ->

    7.0.0

  • • Microsoft.Extensions.Http.Polly

    5.0.*

    ->

    7.0.0

  • • NSubstitute

    4.2.2

    ->

    4.3.0

  • • Shouldly

    4.0.3

    無需更新
  • • xunit

    2.4.1

    無需更新
  • • xunit.extensibility.execution

    2.4.1

    無需更新
  • • xunit.runner.visualstudio

    2.4.3

    ->

    2.4.5

第三步:編譯解決方案

執行

dotnet build

編譯整個解決方案,編譯成功。如果存在警告或錯誤,檢查程式集版本是否設定正确。

第四步:更新資料庫結構

更新 dotnet-ef 工具

dotnet tool update --global dotnet-ef           

工具 dotnet-ef 更新到目前最新版本

7.0.1

執行指令生成資料遷移腳本:

cd 'src/AbpClub.EntityFrameworkCore'
dotnet ef migrations add UpdateSeven           

需要在資料庫中新增四張表:

  • AbpFeatureGroups

    功能組表
  • AbpFeatures

    功能表
  • AbpPermissionGroups

    權限組表
  • AbpPermissions

    權限表

這四張表用于功能和權限的持久化,以支援動态功能和動态權限。

CmsPages

表中新增列

IsHomePage

,辨別是否是首頁。

詳細的資料庫結構的改動,可以檢視

AbpClub.EntityFrameworkCore

項目中

Migrations

目錄下的

xxxxx_UpdateSeven

類。

接下來,執行

dotnet ef database update

将資料遷移腳本更新到資料庫。

第五步:更新前端包

AbpClub.Web

項目中找到包配置檔案

packages.json

,将

@abp

為字首的所有NPM包更新到最新版本号。

原版本:

{
"version": "1.0.0",
"name": "abpclub",
"private": true,
"dependencies": {
"@abp/aspnetcore.mvc.ui.theme.leptonxlite": "~1.0.0",
"@abp/cms-kit": "6.0.1",
"@abp/docs": "6.0.1",
"@abp/jstree": "6.0.1",
"@abp/tui-editor": "6.0.1",
"@abp/uppy": "6.0.1",
"@abp/virtual-file-explorer": "6.0.1",
"slugify": "1.6.5",
"tui-code-snippet": "2.3.3"
 }
}           

更新為:

{
"version": "1.0.0",
"name": "abpclub",
"private": true,
"dependencies": {
"@abp/aspnetcore.mvc.ui.theme.leptonxlite": "~2.0.0",
"@abp/cms-kit": "7.0.0",
"@abp/docs": "7.0.0",
"@abp/jstree": "7.0.0",
"@abp/tui-editor": "7.0.0",
"@abp/uppy": "7.0.0",
"@abp/virtual-file-explorer": "7.0.0",
"slugify": "1.6.5",
"tui-code-snippet": "2.3.3"
 }
}           

slugify

tui-code-snippet

沒有新版本,無需更新。

終端工具導航到 Web 項目所在目錄,然後執行

abp install-libs

更新包引用。

除了

Web

項目,别忘記将

IdentityServer

項目按照同樣的方式進行更新。

{
"version": "1.0.0",
"name": "my-app-identityserver",
"private": true,
"dependencies": {
"@abp/aspnetcore.mvc.ui.theme.leptonxlite": "~2.0.0"
 }
}           

第六步:功能測試

分别啟動

IdentityServer

HttpApi.Host

以及

Web

項目,測試應用中的功能是否都正常。

6.0.1

版本中存在的問題,在目前版本中已經修複:通路CMS菜單下除評論外的其他6個頁面已經不會抛出異常。

  • • 部落格:

    https://localhost:44397/Cms/Blogs

  • • 部落格文章:

    https://localhost:44397/Cms/BlogPosts

  • • 菜單:

    https://localhost:44397/Cms/Menus/Items

  • • 頁面:

    https://localhost:44397/Cms/Pages

  • • 标簽:

    https://localhost:44397/Cms/Tags

檢視源碼,已經在

/Themes/LeptonXLite/Layouts/Application.cshtml

頁面中修複了該Bug,設定

content_toolbar

Section 為非必要渲染。

修複方式:

@await RenderSectionAsync("content_toolbar", false)           

更新成功!目前的感受是,版本的穩定性進一步增強了。

本文已收錄到《ABP Framework 極速開發》

繼續閱讀