Skip to content

Commit bc2fff3

Browse files
authored
Merge pull request #1250 from colinin/update-micro-templates
feat(templates): Upgrade the microservice startup template to version…
2 parents 7593e98 + c6b54ba commit bc2fff3

8 files changed

Lines changed: 155 additions & 58 deletions

File tree

aspnet-core/templates/micro/PackageName.CompanyName.ProjectName.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework> <!-- 或其他适合的框架 -->
3+
<TargetFramework>net9.0</TargetFramework>
44
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
55
<PackageId>LINGYUN.Abp.MicroService.Templates</PackageId>
6-
<Version>9.1.1</Version>
6+
<Version>9.2.0</Version>
77
<Authors>colin.in@foxmail.com</Authors>
88
<Description>Abp framework micro-service template</Description>
99
<PackageLicenseExpression>MIT</PackageLicenseExpression>

aspnet-core/templates/micro/content/Directory.Packages.props

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<Project>
22
<PropertyGroup>
3-
<DotNetCoreCAPPackageVersion>8.3.2</DotNetCoreCAPPackageVersion>
4-
<ElsaPackageVersion>2.14.1</ElsaPackageVersion>
5-
<VoloAbpPackageVersion>9.1.1</VoloAbpPackageVersion>
6-
<LINGYUNAbpPackageVersion>9.1.1</LINGYUNAbpPackageVersion>
7-
<MicrosoftExtensionsPackageVersion>9.0.0.0</MicrosoftExtensionsPackageVersion>
8-
<MicrosoftAspNetCorePackageVersion>9.0.0.0</MicrosoftAspNetCorePackageVersion>
9-
<MicrosoftEntityFrameworkCorePackageVersion>9.0.0.0</MicrosoftEntityFrameworkCorePackageVersion>
3+
<DotNetCoreCAPPackageVersion>8.3.5</DotNetCoreCAPPackageVersion>
4+
<ElsaPackageVersion>2.15.1</ElsaPackageVersion>
5+
<VoloAbpPackageVersion>9.2.0</VoloAbpPackageVersion>
6+
<LINGYUNAbpPackageVersion>9.2.0</LINGYUNAbpPackageVersion>
7+
<MicrosoftExtensionsPackageVersion>9.0.4</MicrosoftExtensionsPackageVersion>
8+
<MicrosoftAspNetCorePackageVersion>9.0.4</MicrosoftAspNetCorePackageVersion>
9+
<MicrosoftEntityFrameworkCorePackageVersion>9.0.4</MicrosoftEntityFrameworkCorePackageVersion>
1010
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1111
</PropertyGroup>
1212

1313
<!-- LINGYUN Abp Framework -->
1414
<ItemGroup>
15+
<PackageVersion Include="LINGYUN.Abp.Claims.Mapping" Version="$(LINGYUNAbpPackageVersion)" />
1516
<PackageVersion Include="LINGYUN.Abp.AspNetCore.HttpOverrides" Version="$(LINGYUNAbpPackageVersion)" />
1617
<PackageVersion Include="LINGYUN.Abp.AspNetCore.Mvc.Localization" Version="$(LINGYUNAbpPackageVersion)" />
1718
<PackageVersion Include="LINGYUN.Abp.AspNetCore.Mvc.Wrapper" Version="$(LINGYUNAbpPackageVersion)" />
@@ -84,7 +85,6 @@
8485
<PackageVersion Include="LINGYUN.Abp.Features.LimitValidation" Version="$(LINGYUNAbpPackageVersion)" />
8586
<PackageVersion Include="LINGYUN.Abp.RealTime" Version="$(LINGYUNAbpPackageVersion)" />
8687
<PackageVersion Include="LINGYUN.Abp.Wrapper" Version="$(LINGYUNAbpPackageVersion)" />
87-
<PackageVersion Include="LINGYUN.Abp.Exporter.MiniExcel" Version="$(LINGYUNAbpPackageVersion)" />
8888
<PackageVersion Include="LINGYUN.Abp.FeatureManagement.Client" Version="$(LINGYUNAbpPackageVersion)" />
8989
<PackageVersion Include="LINGYUN.Abp.Localization.Persistence" Version="$(LINGYUNAbpPackageVersion)" />
9090
<PackageVersion Include="LINGYUN.Abp.Logging.Serilog.Elasticsearch" Version="$(LINGYUNAbpPackageVersion)" />
@@ -243,7 +243,7 @@
243243

244244
<!-- Abp Framework -->
245245
<ItemGroup>
246-
<PackageVersion Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite" Version="4.1.1" />
246+
<PackageVersion Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite" Version="4.2.0" />
247247
<PackageVersion Include="Volo.Abp.Core" Version="$(VoloAbpPackageVersion)" />
248248
<PackageVersion Include="Volo.Abp.Account.Application" Version="$(VoloAbpPackageVersion)" />
249249
<PackageVersion Include="Volo.Abp.Account.Application.Contracts" Version="$(VoloAbpPackageVersion)" />
@@ -428,71 +428,71 @@
428428

429429
<!-- Serilog -->
430430
<ItemGroup>
431-
<PackageVersion Include="Serilog" Version="4.0.2" />
432-
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.2" />
433-
<PackageVersion Include="Serilog.Enrichers.Environment" Version="2.3.0" />
431+
<PackageVersion Include="Serilog" Version="4.2.0" />
432+
<PackageVersion Include="Serilog.AspNetCore" Version="9.0.0" />
433+
<PackageVersion Include="Serilog.Enrichers.Environment" Version="3.0.1" />
434434
<PackageVersion Include="Serilog.Enrichers.Assembly" Version="2.0.0" />
435-
<PackageVersion Include="Serilog.Enrichers.Process" Version="2.0.2" />
436-
<PackageVersion Include="Serilog.Enrichers.Thread" Version="3.1.0" />
437-
<PackageVersion Include="Serilog.Extensions.Hosting" Version="8.0.0" />
438-
<PackageVersion Include="Serilog.Extensions.Logging" Version="8.0.0" />
439-
<PackageVersion Include="Serilog.Settings.Configuration" Version="8.0.2" />
440-
<PackageVersion Include="Serilog.Sinks.Async" Version="2.0.0" />
435+
<PackageVersion Include="Serilog.Enrichers.Process" Version="3.0.0" />
436+
<PackageVersion Include="Serilog.Enrichers.Thread" Version="4.0.0" />
437+
<PackageVersion Include="Serilog.Extensions.Hosting" Version="9.0.0" />
438+
<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.1" />
439+
<PackageVersion Include="Serilog.Settings.Configuration" Version="9.0.0" />
440+
<PackageVersion Include="Serilog.Sinks.Async" Version="2.1.0" />
441441
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" />
442442
<PackageVersion Include="Serilog.Sinks.Elasticsearch" Version="9.0.3" />
443-
<PackageVersion Include="Serilog.Sinks.File" Version="6.0.0" />
443+
<PackageVersion Include="Serilog.Sinks.File" Version="7.0.0" />
444444
</ItemGroup>
445445

446446
<!-- Test -->
447447
<ItemGroup>
448-
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
449-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
450-
<PackageVersion Include="Moq.AutoMock" Version="3.0.0" />
451-
<PackageVersion Include="NSubstitute" Version="5.1.0" />
452-
<PackageVersion Include="Shouldly" Version="4.2.1" />
453-
<PackageVersion Include="xunit" Version="2.9.2" />
454-
<PackageVersion Include="xunit.extensibility.execution" Version="2.9.2" />
455-
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
448+
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
449+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
450+
<PackageVersion Include="Moq.AutoMock" Version="3.5.0" />
451+
<PackageVersion Include="NSubstitute" Version="5.3.0" />
452+
<PackageVersion Include="Shouldly" Version="4.3.0" />
453+
<PackageVersion Include="xunit" Version="2.9.3" />
454+
<PackageVersion Include="xunit.extensibility.execution" Version="2.9.3" />
455+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
456456
</ItemGroup>
457457

458458
<!-- Fody -->
459459
<ItemGroup>
460460
<PackageVersion Include="ConfigureAwait.Fody" Version="3.3.2" />
461-
<PackageVersion Include="Fody" Version="6.8.0" />
461+
<PackageVersion Include="Fody" Version="6.9.2" />
462462
</ItemGroup>
463463

464464
<!-- Other -->
465465
<ItemGroup>
466466
<PackageVersion Include="aliyun-net-sdk-core" Version="1.5.10" />
467467
<PackageVersion Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
468468
<PackageVersion Include="AgileConfig.Client" Version="1.6.9" />
469-
<PackageVersion Include="Dapr.Client" Version="1.14.0" />
470-
<PackageVersion Include="Dapr.Actors" Version="1.14.0" />
471-
<PackageVersion Include="Dapr.Actors.AspNetCore" Version="1.14.0" />
472-
<PackageVersion Include="DistributedLock.Core" Version="1.0.7" />
469+
<PackageVersion Include="Dapr.Client" Version="1.15.4" />
470+
<PackageVersion Include="Dapr.Actors" Version="1.15.4" />
471+
<PackageVersion Include="Dapr.Actors.AspNetCore" Version="1.15.4" />
472+
<PackageVersion Include="DistributedLock.Core" Version="1.0.8" />
473473
<PackageVersion Include="DistributedLock.Redis" Version="1.0.3" />
474474
<PackageVersion Include="Hangfire.MySqlStorage" Version="2.0.3" />
475-
<PackageVersion Include="HangFire.SqlServer" Version="1.8.17" />
475+
<PackageVersion Include="HangFire.SqlServer" Version="1.8.18" />
476476
<PackageVersion Include="IdentityModel" Version="7.0.0" />
477-
<PackageVersion Include="JetBrains.Annotations" Version="2024.2.0" />
477+
<PackageVersion Include="JetBrains.Annotations" Version="2024.3.0" />
478478
<PackageVersion Include="Markdig" Version="0.34.0" />
479479
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
480480
<PackageVersion Include="NEST" Version="7.17.5" />
481481
<PackageVersion Include="NRules" Version="0.9.2" />
482482
<PackageVersion Include="Ocelot.Provider.Polly" Version="20.0.0" />
483-
<PackageVersion Include="Polly" Version="8.4.2" />
484-
<PackageVersion Include="Quartz.Serialization.Json" Version="3.13.0" />
483+
<PackageVersion Include="Polly" Version="8.5.2" />
484+
<PackageVersion Include="Quartz.Serialization.Json" Version="3.14.0" />
485485
<PackageVersion Include="RulesEngine" Version="5.0.5" />
486486
<PackageVersion Include="Senparc.Weixin.MP" Version="16.18.9" />
487-
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.5" />
488-
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="2.1.4" />
489-
<PackageVersion Include="StackExchange.Redis" Version="2.8.16" />
490-
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.8.1" />
487+
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.8" />
488+
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="2.1.6" />
489+
<PackageVersion Include="StackExchange.Redis" Version="2.8.31" />
490+
<PackageVersion Include="Swashbuckle.AspNetCore" Version="8.1.1" />
491491
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
492492
<PackageVersion Include="Tencent.QCloud.Cos.Sdk" Version="5.4.37" />
493493
<PackageVersion Include="TencentCloudSDK" Version="3.0.712" />
494494
<PackageVersion Include="Yarp.ReverseProxy" Version="2.1.0" />
495-
<PackageVersion Include="OpenIddict.Server.DataProtection" Version="6.0.0" />
496-
<PackageVersion Include="OpenIddict.Validation.DataProtection" Version="6.0.0" />
495+
<PackageVersion Include="OpenIddict.Server.DataProtection" Version="6.2.1" />
496+
<PackageVersion Include="OpenIddict.Validation.DataProtection" Version="6.2.1" />
497497
</ItemGroup>
498498
</Project>

aspnet-core/templates/micro/content/common.props

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project>
22
<PropertyGroup>
33
<LangVersion>latest</LangVersion>
4-
<Version>9.1.1</Version>
4+
<Version>9.2.0</Version>
55
<Authors>colin</Authors>
66
<NoWarn>$(NoWarn);CS1591;CS0436;CS8618;NU1803</NoWarn>
77
<PackageProjectUrl>https://github.com/colinin/abp-next-admin</PackageProjectUrl>
88
<PackageOutputPath>$(SolutionDir)LocalNuget</PackageOutputPath>
9-
<PackageVersion>9.1.1</PackageVersion>
9+
<PackageVersion>9.2.0</PackageVersion>
1010
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1111
<RepositoryType>git</RepositoryType>
1212
<RepositoryUrl>https://github.com/colinin/abp-next-admin</RepositoryUrl>
@@ -35,4 +35,8 @@
3535
<OutputPath>$(SolutionDir)LocalNuget</OutputPath>
3636
</PropertyGroup>
3737

38+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
39+
<OutputPath>$(SolutionDir)LocalNuget</OutputPath>
40+
</PropertyGroup>
41+
3842
</Project>

aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/PackageName.CompanyName.ProjectName.HttpApi.Host.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<PackageReference Include="DotNetCore.CAP.PostgreSql" Condition="'$(PostgreSql)'=='true'" />
1616
<PackageReference Include="DotNetCore.CAP.Sqlite" Condition="'$(Sqlite)'=='true'" />
1717
<PackageReference Include="DotNetCore.CAP.RabbitMQ" />
18+
<PackageReference Include="LINGYUN.Abp.Claims.Mapping" />
1819
<PackageReference Include="LINGYUN.Abp.AspNetCore.HttpOverrides" />
19-
<PackageReference Include="LINGYUN.Abp.AspNetCore.Mvc.Localization" />
2020
<PackageReference Include="LINGYUN.Abp.AspNetCore.Mvc.Wrapper" />
2121
<PackageReference Include="LINGYUN.Abp.AuditLogging.Elasticsearch" />
2222
<PackageReference Include="LINGYUN.Abp.Data.DbMigrator" />
@@ -60,8 +60,8 @@
6060
</ItemGroup>
6161

6262
<ItemGroup>
63+
<ProjectReference Include="..\..\migrations\PackageName.CompanyName.ProjectName.DbMigrator.EntityFrameworkCore\PackageName.CompanyName.ProjectName.DbMigrator.EntityFrameworkCore.csproj" />
6364
<ProjectReference Include="..\..\src\PackageName.CompanyName.ProjectName.Application\PackageName.CompanyName.ProjectName.Application.csproj" />
64-
<ProjectReference Include="..\..\src\PackageName.CompanyName.ProjectName.EntityFrameworkCore\PackageName.CompanyName.ProjectName.EntityFrameworkCore.csproj" />
6565
<ProjectReference Include="..\..\src\PackageName.CompanyName.ProjectName.HttpApi\PackageName.CompanyName.ProjectName.HttpApi.csproj" />
6666
<ProjectReference Include="..\..\src\PackageName.CompanyName.ProjectName.SettingManagement\PackageName.CompanyName.ProjectName.SettingManagement.csproj" />
6767
</ItemGroup>

aspnet-core/templates/micro/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.Configure.cs

Lines changed: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using LINGYUN.Abp.LocalizationManagement;
88
using LINGYUN.Abp.Serilog.Enrichers.Application;
99
using LINGYUN.Abp.Serilog.Enrichers.UniqueId;
10+
using LINGYUN.Abp.TextTemplating;
1011
using LINGYUN.Abp.Wrapper;
1112
using Medallion.Threading;
1213
using Medallion.Threading.Redis;
@@ -18,10 +19,11 @@
1819
using Microsoft.Extensions.Caching.StackExchangeRedis;
1920
using Microsoft.Extensions.Configuration;
2021
using Microsoft.Extensions.DependencyInjection;
22+
using Microsoft.IdentityModel.Tokens;
2123
using Microsoft.OpenApi.Models;
22-
using PackageName.CompanyName.ProjectName.Localization;
2324
using StackExchange.Redis;
2425
using System;
26+
using System.Collections.Generic;
2527
using System.Linq;
2628
using System.Text.Encodings.Web;
2729
using System.Text.Unicode;
@@ -30,13 +32,16 @@
3032
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
3133
using Volo.Abp.Auditing;
3234
using Volo.Abp.Caching;
35+
using Volo.Abp.FeatureManagement;
3336
using Volo.Abp.GlobalFeatures;
3437
using Volo.Abp.Http.Client;
3538
using Volo.Abp.Json;
3639
using Volo.Abp.Json.SystemTextJson;
3740
using Volo.Abp.Localization;
3841
using Volo.Abp.MultiTenancy;
42+
using Volo.Abp.PermissionManagement;
3943
using Volo.Abp.Security.Claims;
44+
using Volo.Abp.SettingManagement;
4045
using Volo.Abp.Threading;
4146
using Volo.Abp.Timing;
4247
using Volo.Abp.VirtualFileSystem;
@@ -46,7 +51,6 @@ namespace PackageName.CompanyName.ProjectName;
4651
public partial class ProjectNameHttpApiHostModule
4752
{
4853
public static string ApplicationName { get; set; } = "ProjectNameService";
49-
private const string DefaultCorsPolicyName = "Default";
5054
private static readonly OneTimeRunner OneTimeRunner = new();
5155

5256
private void PreConfigureFeature()
@@ -235,6 +239,54 @@ private void ConfigureMiniExcel()
235239
});
236240
}
237241

242+
private void ConfigureFeatureManagement(IConfiguration configuration)
243+
{
244+
if (configuration.GetValue("FeatureManagement:IsDynamicStoreEnabled", false))
245+
{
246+
Configure<FeatureManagementOptions>(options =>
247+
{
248+
options.SaveStaticFeaturesToDatabase = true;
249+
options.IsDynamicFeatureStoreEnabled = true;
250+
});
251+
}
252+
}
253+
254+
private void ConfigurePermissionManagement(IConfiguration configuration)
255+
{
256+
if (configuration.GetValue("PermissionManagement:IsDynamicStoreEnabled", false))
257+
{
258+
Configure<PermissionManagementOptions>(options =>
259+
{
260+
options.SaveStaticPermissionsToDatabase = true;
261+
options.IsDynamicPermissionStoreEnabled = true;
262+
});
263+
}
264+
}
265+
266+
private void ConfigureTextTemplatingManagement(IConfiguration configuration)
267+
{
268+
if (configuration.GetValue("TextTemplatingManagement:IsDynamicStoreEnabled", false))
269+
{
270+
Configure<AbpTextTemplatingCachingOptions>(options =>
271+
{
272+
options.SaveStaticTemplateDefinitionToDatabase = true;
273+
options.IsDynamicTemplateDefinitionStoreEnabled = true;
274+
});
275+
}
276+
}
277+
278+
private void ConfigureSettingManagement(IConfiguration configuration)
279+
{
280+
if (configuration.GetValue("SettingManagement:IsDynamicStoreEnabled", false))
281+
{
282+
Configure<SettingManagementOptions>(options =>
283+
{
284+
options.SaveStaticSettingsToDatabase = true;
285+
options.IsDynamicSettingStoreEnabled = true;
286+
});
287+
}
288+
}
289+
238290
private void ConfigureVirtualFileSystem()
239291
{
240292
Configure<AbpVirtualFileSystemOptions>(options =>
@@ -294,10 +346,11 @@ private void ConfigureSwagger(IServiceCollection services)
294346
}
295347
});
296348
options.OperationFilter<TenantHeaderParamter>();
349+
options.HideAbpEndpoints();
297350
});
298351
}
299352

300-
private void ConfigureLocalization()
353+
private void ConfigureLocalization(IConfiguration configuration)
301354
{
302355
// 支持本地化语言类型
303356
Configure<AbpLocalizationOptions>(options =>
@@ -318,10 +371,13 @@ private void ConfigureLocalization()
318371
options.UiCulturesMaps.Add(zhHansCultureMapInfo);
319372
});
320373

321-
Configure<AbpLocalizationManagementOptions>(options =>
374+
if (configuration.GetValue("LocalizationManagement:IsDynamicStoreEnabled", false))
322375
{
323-
options.SaveStaticLocalizationsToDatabase = true;
324-
});
376+
Configure<AbpLocalizationManagementOptions>(options =>
377+
{
378+
options.SaveStaticLocalizationsToDatabase = true;
379+
});
380+
}
325381
}
326382

327383
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false)
@@ -333,9 +389,16 @@ private void ConfigureSecurity(IServiceCollection services, IConfiguration confi
333389
});
334390

335391
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
336-
.AddJwtBearer(options =>
392+
.AddAbpJwtBearer(options =>
337393
{
338394
configuration.GetSection("AuthServer").Bind(options);
395+
396+
var validIssuers = configuration.GetSection("AuthServer:ValidIssuers").Get<List<string>>();
397+
if (validIssuers?.Count > 0)
398+
{
399+
options.TokenValidationParameters.ValidIssuers = validIssuers;
400+
options.TokenValidationParameters.IssuerValidator = TokenWildcardIssuerValidator.IssuerValidator;
401+
}
339402
});
340403

341404
if (!isDevelopment)
@@ -352,7 +415,7 @@ private void ConfigureCors(IServiceCollection services, IConfiguration configura
352415
{
353416
services.AddCors(options =>
354417
{
355-
options.AddPolicy(DefaultCorsPolicyName, builder =>
418+
options.AddDefaultPolicy(builder =>
356419
{
357420
builder
358421
.WithOrigins(

0 commit comments

Comments
 (0)