RiverLi.Blog.Infrastructure.Shared 1.0.3

dotnet add package RiverLi.Blog.Infrastructure.Shared --version 1.0.3
                    
NuGet\Install-Package RiverLi.Blog.Infrastructure.Shared -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RiverLi.Blog.Infrastructure.Shared" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RiverLi.Blog.Infrastructure.Shared" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="RiverLi.Blog.Infrastructure.Shared" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RiverLi.Blog.Infrastructure.Shared --version 1.0.3
                    
#r "nuget: RiverLi.Blog.Infrastructure.Shared, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RiverLi.Blog.Infrastructure.Shared@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RiverLi.Blog.Infrastructure.Shared&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=RiverLi.Blog.Infrastructure.Shared&version=1.0.3
                    
Install as a Cake Tool

RiverLi.Blog.Infrastructure.Shared

RiverLi.Blog 微服务集群通用 DDD 基础设施共享库,包含 EFCore 实现、MassTransit 实现和 Redis 实现。

概述

这是一个为 RiverLi.Blog 微服务集群提供通用基础设施组件的共享库。它包含了常见的基础设施功能实现,如数据访问、缓存、事件总线等。

功能特性

  • 数据访问: 基于 Entity Framework Core 的仓储模式实现
  • 缓存: 基于 Redis 的缓存服务
  • 事件总线: 基于 MassTransit 和 RabbitMQ 的事件发布机制
  • 认证: JWT 认证相关配置
  • 健康检查: 集成 ASP.NET Core 健康检查功能
  • 日志记录: 使用 Serilog 进行结构化日志记录
  • 弹性策略: 集成 Polly 提供重试和断路器功能
  • 分布式追踪: OpenTelemetry 支持

依赖项

  • .NET 9.0
  • Entity Framework Core
  • MassTransit (RabbitMQ)
  • StackExchange Redis
  • MediatR
  • Serilog
  • OpenTelemetry
  • Health Checks

安装

Install-Package RiverLi.Blog.Infrastructure.Shared

dotnet add package RiverLi.Blog.Infrastructure.Shared

NuGet 包打包和发布

前置要求

  1. .NET 9.0 SDK 或更高版本
  2. NuGet.org API Key (用于上传到公共源)
  3. 如果 RiverLi.DDD.Core 未作为 NuGet 包发布,需要先处理依赖关系

打包步骤

方式一: 使用自动化脚本(推荐)
# 运行打包脚本
.\publish-nuget.ps1

脚本会自动执行:

  • 清理构建产物
  • 还原依赖
  • 构建项目(Release 模式)
  • 生成 NuGet 包
  • 可选: 上传到 NuGet.org
方式二: 手动打包
# 1. 清理
dotnet clean --configuration Release

# 2. 还原依赖
dotnet restore

# 3. 构建
dotnet build --configuration Release

# 4. 打包
dotnet pack --configuration Release --output ./nupkg

生成的包位于 ./nupkg 目录中。

上传到 NuGet.org

# 设置 API Key(只需一次)
dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org

# 上传包
dotnet nuget push ./nupkg/RiverLi.Blog.Infrastructure.Shared.1.0.3.nupkg --api-key YOUR_API_KEY --source nuget.org

或使用环境变量:

# 设置环境变量
$env:NUGET_API_KEY="your-api-key-here"

# 运行脚本并自动上传
.\publish-nuget.ps1

版本号管理

修改 .csproj 文件中的 <Version> 属性:

<PropertyGroup>
  <Version>1.0.4</Version> 
</PropertyGroup>

遵循 语义化版本 规范:

  • 主版本号: 不兼容的 API 修改
  • 次版本号: 向下兼容的功能性新增
  • 修订号: 向下兼容的问题修正

注意事项

  1. 外部依赖: 本项目引用了 RiverLi.DDD.Core,需要确保:

    • 该依赖已发布为 NuGet 包,或
    • 在打包时调整项目结构
  2. 符号包: 配置已启用符号包生成(.snupkg),支持远程调试

  3. 包验证: 上传前可使用以下命令验证包:

    dotnet nuget verify ./nupkg/RiverLi.Blog.Infrastructure.Shared.1.0.3.nupkg
    
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 82 7/11/2026