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:
+93
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Company.Project.Shared;
|
||||
using ProductManagement;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.AspNetCore.Mvc.Client;
|
||||
using Volo.Abp.Autofac;
|
||||
using Volo.Abp.Http.Client.IdentityModel.Web;
|
||||
using Volo.Abp.Identity.Web;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using Ocelot.DependencyInjection;
|
||||
using Ocelot.Middleware;
|
||||
|
||||
namespace Company.Project.BackendAdminAppGateway;
|
||||
|
||||
[DependsOn(
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpHttpClientIdentityModelWebModule),
|
||||
typeof(AbpIdentityWebModule),
|
||||
typeof(AbpAspNetCoreMvcClientModule),
|
||||
typeof(ProductManagementHttpApiModule),
|
||||
typeof(ProductManagementWebModule)
|
||||
)]
|
||||
public class BackendAdminAppGatewayHostModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
|
||||
Configure<AbpMultiTenancyOptions>(options =>
|
||||
{
|
||||
options.IsEnabled = ProjectConsts.IsMultiTenancyEnabled;
|
||||
});
|
||||
|
||||
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
options.Authority = configuration["AuthServer:Authority"];
|
||||
options.Audience = configuration["AuthServer:ApiName"];
|
||||
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
|
||||
});
|
||||
|
||||
context.Services.AddSwaggerGen(options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new OpenApiInfo { Title = "BackendAdminApp Gateway API", Version = "v1" });
|
||||
options.DocInclusionPredicate((docName, description) => true);
|
||||
options.CustomSchemaIds(type => type.FullName);
|
||||
});
|
||||
|
||||
context.Services.AddOcelot(configuration);
|
||||
}
|
||||
|
||||
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
||||
{
|
||||
var app = context.GetApplicationBuilder();
|
||||
|
||||
app.UseCorrelationId();
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
app.UseAuthentication();
|
||||
app.UseAbpClaimsMap();
|
||||
|
||||
if (ProjectConsts.IsMultiTenancyEnabled)
|
||||
{
|
||||
app.UseMultiTenancy();
|
||||
}
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(options =>
|
||||
{
|
||||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "BackendAdminApp Gateway API");
|
||||
});
|
||||
|
||||
app.UseAbpRequestLocalization();
|
||||
|
||||
app.MapWhen(
|
||||
ctx => ctx.Request.Path.ToString().StartsWith("/api/abp/") ||
|
||||
ctx.Request.Path.ToString().StartsWith("/Abp/") ||
|
||||
ctx.Request.Path.ToString().StartsWith("/api/identity/"),
|
||||
app2 =>
|
||||
{
|
||||
app2.UseRouting();
|
||||
app2.UseConfiguredEndpoints();
|
||||
}
|
||||
);
|
||||
|
||||
app.UseOcelot().Wait();
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>Company.Project.BackendAdminAppGateway</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Autofac" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel.Web" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.Identity.Web" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.Client" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||
<PackageReference Include="Ocelot" Version="18.0.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
|
||||
<ProjectReference Include="..\..\modules\product\src\ProductManagement.HttpApi.Client\ProductManagement.HttpApi.Client.csproj" />
|
||||
<ProjectReference Include="..\..\modules\product\src\ProductManagement.Web\ProductManagement.Web.csproj" />
|
||||
<ProjectReference Include="..\..\shared\Company.Project.Shared\Company.Project.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,23 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["gateways/Company.Project.BackendAdminAppGateway.Host/Company.Project.BackendAdminAppGateway.Host.csproj", "gateways/Company.Project.BackendAdminAppGateway.Host/"]
|
||||
COPY ["modules/product/src/ProductManagement.HttpApi/ProductManagement.HttpApi.csproj", "modules/product/src/ProductManagement.HttpApi/"]
|
||||
COPY ["modules/product/src/ProductManagement.Application.Contracts/ProductManagement.Application.Contracts.csproj", "modules/product/src/ProductManagement.Application.Contracts/"]
|
||||
COPY ["modules/product/src/ProductManagement.Domain.Shared/ProductManagement.Domain.Shared.csproj", "modules/product/src/ProductManagement.Domain.Shared/"]
|
||||
COPY ["shared/Company.Project.Shared/Company.Project.Shared.csproj", "shared/Company.Project.Shared/"]
|
||||
RUN dotnet restore "gateways/Company.Project.BackendAdminAppGateway.Host/Company.Project.BackendAdminAppGateway.Host.csproj" -nowarn:msb3202,msb3277,nu1503
|
||||
COPY . .
|
||||
WORKDIR "/src/gateways/Company.Project.BackendAdminAppGateway.Host"
|
||||
RUN dotnet build "Company.Project.BackendAdminAppGateway.Host.csproj" --no-restore -nowarn:msb3202,msb3277,nu1503 -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "Company.Project.BackendAdminAppGateway.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.BackendAdminAppGateway.Host.dll"]
|
||||
@@ -0,0 +1,23 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["gateways/Company.Project.BackendAdminAppGateway.Host/Company.Project.BackendAdminAppGateway.Host.csproj", "gateways/Company.Project.BackendAdminAppGateway.Host/"]
|
||||
COPY ["modules/product/src/ProductManagement.HttpApi/ProductManagement.HttpApi.csproj", "modules/product/src/ProductManagement.HttpApi/"]
|
||||
COPY ["modules/product/src/ProductManagement.Application.Contracts/ProductManagement.Application.Contracts.csproj", "modules/product/src/ProductManagement.Application.Contracts/"]
|
||||
COPY ["modules/product/src/ProductManagement.Domain.Shared/ProductManagement.Domain.Shared.csproj", "modules/product/src/ProductManagement.Domain.Shared/"]
|
||||
COPY ["shared/Company.Project.Shared/Company.Project.Shared.csproj", "shared/Company.Project.Shared/"]
|
||||
RUN dotnet restore "gateways/Company.Project.BackendAdminAppGateway.Host/Company.Project.BackendAdminAppGateway.Host.csproj" -nowarn:msb3202,msb3277,nu1503
|
||||
COPY . .
|
||||
WORKDIR "/src/gateways/Company.Project.BackendAdminAppGateway.Host"
|
||||
RUN dotnet build "Company.Project.BackendAdminAppGateway.Host.csproj" --no-restore -nowarn:msb3202,msb3277,nu1503 -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "Company.Project.BackendAdminAppGateway.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.BackendAdminAppGateway.Host.dll"]
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
using Volo.Abp;
|
||||
|
||||
namespace Company.Project.BackendAdminAppGateway;
|
||||
|
||||
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:44315",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Company.Project.BackendAdminAppGateway.Host": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:44315",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Company.Project.BackendAdminAppGateway;
|
||||
|
||||
public class Startup
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddApplication<BackendAdminAppGatewayHostModule>();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostEnvironment env)
|
||||
{
|
||||
app.InitializeApplication();
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug",
|
||||
"System": "Information",
|
||||
"Microsoft": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"AuthServer": {
|
||||
"Authority": "https://localhost:44399",
|
||||
"RequireHttpsMetadata": "true",
|
||||
"ApiName": "BackendAdminAppGateway"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "Server=(LocalDb)\\MSSQLLocalDB; Database=Company.Project_Identity; Trusted_Connection=True"
|
||||
},
|
||||
"Redis": {
|
||||
"Configuration": "localhost:6379"
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information"
|
||||
}
|
||||
},
|
||||
"Routes": [
|
||||
{
|
||||
"DownstreamPathTemplate": "/api/identity/{everything}",
|
||||
"DownstreamScheme": "https",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 44368
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/identity/{everything}",
|
||||
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ]
|
||||
},
|
||||
{
|
||||
"DownstreamPathTemplate": "/api/multi-tenancy/{everything}",
|
||||
"DownstreamScheme": "https",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 44336
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/multi-tenancy/{everything}",
|
||||
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ]
|
||||
},
|
||||
{
|
||||
"DownstreamPathTemplate": "/api/productManagement/{everything}",
|
||||
"DownstreamScheme": "https",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 44344
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/productManagement/{everything}",
|
||||
"UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ]
|
||||
}
|
||||
],
|
||||
"GlobalConfiguration": {
|
||||
"BaseUrl": "https://localhost:44315"
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user