build: 升级目标框架到net10.0并完善模板配置

1. 将Hua.Cli.Tests、项目共享库、模块项目等所有项目的TargetFramework从net8.0/net9.0升级到net10.0
2. 完善dotnet-tools.json、模板配置文件,添加必要的构建和发布配置
3. 新增微服务、网关、应用程序的启动脚本和基础配置文件
4. 补充产品管理模块的领域、应用、Web层基础代码和多语言资源
This commit is contained in:
ShaoHua
2026-07-16 02:43:29 +08:00
parent 2a6f5f81b7
commit 734b2c91f9
264 changed files with 7132 additions and 451 deletions
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Company.Project.ProductService</RootNamespace>
</PropertyGroup>
<ItemGroup>
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
namespace Company.Project.ProductService.Controllers;
public class HomeController : AbpController
{
public ActionResult Index()
{
return Redirect("/swagger");
}
}
@@ -0,0 +1,26 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["microservices/Company.Project.ProductService.Host/Company.Project.ProductService.Host.csproj", "microservices/Company.Project.ProductService.Host/"]
COPY ["modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagement.EntityFrameworkCore.csproj", "modules/product/src/ProductManagement.EntityFrameworkCore/"]
COPY ["modules/product/src/ProductManagement.Domain/ProductManagement.Domain.csproj", "modules/product/src/ProductManagement.Domain/"]
COPY ["modules/product/src/ProductManagement.Domain.Shared/ProductManagement.Domain.Shared.csproj", "modules/product/src/ProductManagement.Domain.Shared/"]
COPY ["modules/product/src/ProductManagement.Application/ProductManagement.Application.csproj", "modules/product/src/ProductManagement.Application/"]
COPY ["modules/product/src/ProductManagement.Application.Contracts/ProductManagement.Application.Contracts.csproj", "modules/product/src/ProductManagement.Application.Contracts/"]
COPY ["modules/product/src/ProductManagement.HttpApi/ProductManagement.HttpApi.csproj", "modules/product/src/ProductManagement.HttpApi/"]
COPY ["shared/Company.Project.Shared/Company.Project.Shared.csproj", "shared/Company.Project.Shared/"]
RUN dotnet restore "microservices/Company.Project.ProductService.Host/Company.Project.ProductService.Host.csproj" -nowarn:msb3202,msb3277,nu1503
COPY . .
WORKDIR "/src/microservices/Company.Project.ProductService.Host"
RUN dotnet build "Company.Project.ProductService.Host.csproj" --no-restore -nowarn:msb3202,msb3277,nu1503 -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Company.Project.ProductService.Host.csproj" --no-restore -nowarn:msb3202,msb3277,nu1503 -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Company.Project.ProductService.Host.dll"]
@@ -0,0 +1,26 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["microservices/Company.Project.ProductService.Host/Company.Project.ProductService.Host.csproj", "microservices/Company.Project.ProductService.Host/"]
COPY ["modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagement.EntityFrameworkCore.csproj", "modules/product/src/ProductManagement.EntityFrameworkCore/"]
COPY ["modules/product/src/ProductManagement.Domain/ProductManagement.Domain.csproj", "modules/product/src/ProductManagement.Domain/"]
COPY ["modules/product/src/ProductManagement.Domain.Shared/ProductManagement.Domain.Shared.csproj", "modules/product/src/ProductManagement.Domain.Shared/"]
COPY ["modules/product/src/ProductManagement.Application/ProductManagement.Application.csproj", "modules/product/src/ProductManagement.Application/"]
COPY ["modules/product/src/ProductManagement.Application.Contracts/ProductManagement.Application.Contracts.csproj", "modules/product/src/ProductManagement.Application.Contracts/"]
COPY ["modules/product/src/ProductManagement.HttpApi/ProductManagement.HttpApi.csproj", "modules/product/src/ProductManagement.HttpApi/"]
COPY ["shared/Company.Project.Shared/Company.Project.Shared.csproj", "shared/Company.Project.Shared/"]
RUN dotnet restore "microservices/Company.Project.ProductService.Host/Company.Project.ProductService.Host.csproj" -nowarn:msb3202,msb3277,nu1503
COPY . .
WORKDIR "/src/microservices/Company.Project.ProductService.Host"
RUN dotnet build "Company.Project.ProductService.Host.csproj" --no-restore -nowarn:msb3202,msb3277,nu1503 -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Company.Project.ProductService.Host.csproj" --no-restore -nowarn:msb3202,msb3277,nu1503 -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Company.Project.ProductService.Host.dll"]
@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore;
using ProductManagement.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
namespace Company.Project.ProductService.EntityFrameworkCore;
public class ProductServiceMigrationDbContext : AbpDbContext<ProductServiceMigrationDbContext>
{
public ProductServiceMigrationDbContext(
DbContextOptions<ProductServiceMigrationDbContext> options
) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigureProductManagement();
}
}
@@ -0,0 +1,28 @@
using System.IO;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace Company.Project.ProductService.EntityFrameworkCore;
public class ProductServiceMigrationDbContextFactory : IDesignTimeDbContextFactory<ProductServiceMigrationDbContext>
{
public ProductServiceMigrationDbContext CreateDbContext(string[] args)
{
var configuration = BuildConfiguration();
var builder = new DbContextOptionsBuilder<ProductServiceMigrationDbContext>()
.UseSqlServer(configuration.GetConnectionString("ProductManagement"));
return new ProductServiceMigrationDbContext(builder.Options);
}
private static IConfigurationRoot BuildConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false);
return builder.Build();
}
}
@@ -0,0 +1,47 @@
using System;
using System.Threading.Tasks;
using ProductManagement;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow;
namespace Company.Project.ProductService;
public class ProductServiceDataSeeder : IDataSeedContributor, ITransientDependency
{
private readonly ProductManager _productManager;
private readonly IRepository<Product, Guid> _productRepository;
public ProductServiceDataSeeder(
IRepository<Product, Guid> productRepository,
ProductManager productManager)
{
_productRepository = productRepository;
_productManager = productManager;
}
[UnitOfWork]
public virtual async Task SeedAsync(DataSeedContext context)
{
await AddProductsAsync();
}
private async Task AddProductsAsync()
{
if (await _productRepository.GetCountAsync() > 0)
{
return;
}
await _productManager.CreateAsync("ABP04918", "Lego Star Wars - 75059 Sandcrawler UCS", 999, 42, "lego.jpg");
await _productManager.CreateAsync("ABP23849", "Nikon AF-S 50mm f/1.8 G Lens", 1499, 56, "nikon.jpg");
await _productManager.CreateAsync("ABP82731", "Beats Solo3 Wireless On-Ear Headphone", 97, 20, "beats.jpg");
await _productManager.CreateAsync("ABP12322", "Rampage Sn-Rw2 Gamer Headphone", 654, 42, "rampage.jpg");
await _productManager.CreateAsync("ABP00291", "Asus Transformer Book T300CHI-FH011H", 1249, 3, "asus.jpg");
await _productManager.CreateAsync("ABP02918", "OKI C332DN Dublex + Network A4 Laser Printer", 215, 6, "oki.jpg");
await _productManager.CreateAsync("ABP11121", "Bluecat Rd810 Mini Led", 449, 13, "bluecat.jpg");
await _productManager.CreateAsync("ABP44432", "Sunny 55\" TV 4K Ultra HD Curved Smart Led TV", 2249, 1, "sunny.jpg");
await _productManager.CreateAsync("ABP37182", "Sony Playstation 4 Slim 500 GB (PAL)", 699, 120, "playstation.jpg");
}
}
@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:44344",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Company.Project.ProductService.Host": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:44344",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}