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:
+26
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>Company.Project.TenantManagementService</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Autofac" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.EventBus.RabbitMQ" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.TenantManagement.HttpApi" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.TenantManagement.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.TenantManagement.Application" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.Identity.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.AuditLogging.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="9.0.0" />
|
||||
<ProjectReference Include="..\..\shared\Company.Project.Shared\Company.Project.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
|
||||
namespace Company.Project.TenantManagementService.Controllers;
|
||||
|
||||
public class HomeController : AbpController
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
return Redirect("/swagger");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
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.TenantManagementService.Host/Company.Project.TenantManagementService.Host.csproj", "microservices/Company.Project.TenantManagementService.Host/"]
|
||||
COPY ["shared/Company.Project.Shared/Company.Project.Shared.csproj", "shared/Company.Project.Shared/"]
|
||||
RUN dotnet restore "microservices/Company.Project.TenantManagementService.Host/Company.Project.TenantManagementService.Host.csproj" -nowarn:msb3202,msb3277,nu1503
|
||||
COPY . .
|
||||
WORKDIR "/src/microservices/Company.Project.TenantManagementService.Host"
|
||||
RUN dotnet build "Company.Project.TenantManagementService.Host.csproj" --no-restore -nowarn:msb3202,msb3277,nu1503 -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "Company.Project.TenantManagementService.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.TenantManagementService.Host.dll"]
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
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.TenantManagementService.Host/Company.Project.TenantManagementService.Host.csproj", "microservices/Company.Project.TenantManagementService.Host/"]
|
||||
COPY ["shared/Company.Project.Shared/Company.Project.Shared.csproj", "shared/Company.Project.Shared/"]
|
||||
RUN dotnet restore "microservices/Company.Project.TenantManagementService.Host/Company.Project.TenantManagementService.Host.csproj" -nowarn:msb3202,msb3277,nu1503
|
||||
COPY . .
|
||||
WORKDIR "/src/microservices/Company.Project.TenantManagementService.Host"
|
||||
RUN dotnet build "Company.Project.TenantManagementService.Host.csproj" --no-restore -nowarn:msb3202,msb3277,nu1503 -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "Company.Project.TenantManagementService.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.TenantManagementService.Host.dll"]
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
|
||||
namespace Company.Project.TenantManagementService;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.CreateLogger();
|
||||
|
||||
try { CreateHostBuilder(args).Build().Run(); }
|
||||
catch (Exception ex) { Log.Fatal(ex, "Host terminated unexpectedly"); }
|
||||
finally { Log.CloseAndFlush(); }
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.UseAutofac().UseSerilog()
|
||||
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "https://localhost:44336",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Company.Project.TenantManagementService.Host": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:44336",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Company.Project.TenantManagementService;
|
||||
|
||||
public class Startup
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddApplication<TenantManagementServiceHostModule>();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostEnvironment env)
|
||||
{
|
||||
app.InitializeApplication();
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Company.Project.Shared;
|
||||
using StackExchange.Redis;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.AspNetCore.MultiTenancy;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.AuditLogging.EntityFrameworkCore;
|
||||
using Volo.Abp.Autofac;
|
||||
using Volo.Abp.Domain.Entities.Events.Distributed;
|
||||
using Volo.Abp.EntityFrameworkCore;
|
||||
using Volo.Abp.EntityFrameworkCore.SqlServer;
|
||||
using Volo.Abp.EventBus.RabbitMq;
|
||||
using Volo.Abp.Identity.EntityFrameworkCore;
|
||||
using Volo.Abp.Localization;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
|
||||
using Volo.Abp.SettingManagement.EntityFrameworkCore;
|
||||
using Volo.Abp.TenantManagement;
|
||||
using Volo.Abp.TenantManagement.EntityFrameworkCore;
|
||||
|
||||
namespace Company.Project.TenantManagementService;
|
||||
|
||||
[DependsOn(
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpAspNetCoreMvcModule),
|
||||
typeof(AbpEventBusRabbitMqModule),
|
||||
typeof(AbpEntityFrameworkCoreSqlServerModule),
|
||||
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
|
||||
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
|
||||
typeof(AbpSettingManagementEntityFrameworkCoreModule),
|
||||
typeof(AbpTenantManagementHttpApiModule),
|
||||
typeof(AbpTenantManagementEntityFrameworkCoreModule),
|
||||
typeof(AbpTenantManagementApplicationModule),
|
||||
typeof(AbpAspNetCoreMultiTenancyModule),
|
||||
typeof(AbpIdentityEntityFrameworkCoreModule)
|
||||
)]
|
||||
public class TenantManagementServiceHostModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
|
||||
Configure<AbpMultiTenancyOptions>(options =>
|
||||
{
|
||||
options.IsEnabled = ProjectConsts.IsMultiTenancyEnabled;
|
||||
});
|
||||
|
||||
context.Services.AddAuthentication("Bearer")
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
options.Authority = configuration["AuthServer:Authority"];
|
||||
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
|
||||
options.Audience = configuration["AuthServer:ApiName"];
|
||||
});
|
||||
|
||||
context.Services.AddSwaggerGen(options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Tenant Management Service API", Version = "v1" });
|
||||
options.DocInclusionPredicate((_, _) => true);
|
||||
options.CustomSchemaIds(type => type.FullName);
|
||||
});
|
||||
|
||||
Configure<AbpLocalizationOptions>(options =>
|
||||
{
|
||||
options.Languages.Add(new LanguageInfo("en", "en", "English"));
|
||||
});
|
||||
|
||||
Configure<AbpDistributedEntityEventOptions>(options =>
|
||||
{
|
||||
options.AutoEventSelectors.Add<Tenant>();
|
||||
});
|
||||
|
||||
Configure<AbpDbContextOptions>(options => options.UseSqlServer());
|
||||
|
||||
context.Services.AddStackExchangeRedisCache(options =>
|
||||
{
|
||||
options.Configuration = configuration["Redis:Configuration"];
|
||||
});
|
||||
|
||||
Configure<AbpAuditingOptions>(options =>
|
||||
{
|
||||
options.IsEnabledForGetRequests = true;
|
||||
options.ApplicationName = "TenantManagementService";
|
||||
});
|
||||
|
||||
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
|
||||
context.Services.AddDataProtection()
|
||||
.PersistKeysToStackExchangeRedis(redis, "Company.Project-DataProtection-Keys");
|
||||
}
|
||||
|
||||
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
||||
{
|
||||
var app = context.GetApplicationBuilder();
|
||||
|
||||
app.UseCorrelationId();
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
app.UseAuthentication();
|
||||
|
||||
if (ProjectConsts.IsMultiTenancyEnabled)
|
||||
{
|
||||
app.UseMultiTenancy();
|
||||
}
|
||||
|
||||
app.UseAbpRequestLocalization();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(options =>
|
||||
{
|
||||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Tenant Management Service API");
|
||||
});
|
||||
app.UseAuditing();
|
||||
app.UseConfiguredEndpoints();
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug",
|
||||
"System": "Information",
|
||||
"Microsoft": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"AuthServer": {
|
||||
"Authority": "https://localhost:44399",
|
||||
"RequireHttpsMetadata": "true",
|
||||
"ApiName": "TenantManagementService"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=Company.Project_Identity;Trusted_Connection=True"
|
||||
},
|
||||
"Redis": {
|
||||
"Configuration": "localhost:6379"
|
||||
},
|
||||
"RabbitMQ": {
|
||||
"Connections": {
|
||||
"Default": { "HostName": "localhost" }
|
||||
},
|
||||
"EventBus": {
|
||||
"ClientName": "Company.Project_TenantManagementService",
|
||||
"ExchangeName": "Company.Project"
|
||||
}
|
||||
},
|
||||
"Serilog": { "MinimumLevel": { "Default": "Warning" } },
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user