添加版本信息
This commit is contained in:
parent
5f4af8583a
commit
9282b910ba
|
|
@ -33,16 +33,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TextGenerationApi", "src\2-
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HuanMnegopneaiTest", "src\5-console\HuanMnegopneaiTest\HuanMnegopneaiTest.csproj", "{D2A74CFA-8A03-4272-89C7-C01830D183F1}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HuanMnegopneaiTest", "src\5-console\HuanMnegopneaiTest\HuanMnegopneaiTest.csproj", "{D2A74CFA-8A03-4272-89C7-C01830D183F1}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HuanMeng.MiaoYu.Model", "src\0-core\HuanMeng.MiaoYu.Model\HuanMeng.MiaoYu.Model.csproj", "{B845C884-AD1A-4483-A2F6-B218DB14EA2D}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HuanMeng.MiaoYu.Model", "src\0-core\HuanMeng.MiaoYu.Model\HuanMeng.MiaoYu.Model.csproj", "{B845C884-AD1A-4483-A2F6-B218DB14EA2D}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6C59E75C-386D-4325-9752-D7DB8B158BF8}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6C59E75C-386D-4325-9752-D7DB8B158BF8}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.editorconfig = .editorconfig
|
.editorconfig = .editorconfig
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HuanMeng.MiaoYu.Code", "src\0-core\HuanMeng.MiaoYu.Code\HuanMeng.MiaoYu.Code.csproj", "{6E79742F-1E56-4B7D-94E8-B509D43561FA}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HuanMeng.MiaoYu.Code", "src\0-core\HuanMeng.MiaoYu.Code\HuanMeng.MiaoYu.Code.csproj", "{6E79742F-1E56-4B7D-94E8-B509D43561FA}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HuanMeng.MiaoYu.WebApi", "src\2-api\HuanMeng.MiaoYu.WebApi\HuanMeng.MiaoYu.WebApi.csproj", "{729950F2-71EE-42C0-8B46-295740DE20BA}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HuanMeng.MiaoYu.WebApi", "src\2-api\HuanMeng.MiaoYu.WebApi\HuanMeng.MiaoYu.WebApi.csproj", "{729950F2-71EE-42C0-8B46-295740DE20BA}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HuanMeng.Utility", "src\0-core\HuanMeng.Utility\HuanMeng.Utility.csproj", "{48E1532F-8B50-477C-BB78-8AEA89A167CE}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
@ -90,6 +92,10 @@ Global
|
||||||
{729950F2-71EE-42C0-8B46-295740DE20BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{729950F2-71EE-42C0-8B46-295740DE20BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{729950F2-71EE-42C0-8B46-295740DE20BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{729950F2-71EE-42C0-8B46-295740DE20BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{729950F2-71EE-42C0-8B46-295740DE20BA}.Release|Any CPU.Build.0 = Release|Any CPU
|
{729950F2-71EE-42C0-8B46-295740DE20BA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{48E1532F-8B50-477C-BB78-8AEA89A167CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{48E1532F-8B50-477C-BB78-8AEA89A167CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{48E1532F-8B50-477C-BB78-8AEA89A167CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{48E1532F-8B50-477C-BB78-8AEA89A167CE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
@ -112,6 +118,7 @@ Global
|
||||||
{B845C884-AD1A-4483-A2F6-B218DB14EA2D} = {DD14191F-22CE-48D8-A944-B8A41C97ACD4}
|
{B845C884-AD1A-4483-A2F6-B218DB14EA2D} = {DD14191F-22CE-48D8-A944-B8A41C97ACD4}
|
||||||
{6E79742F-1E56-4B7D-94E8-B509D43561FA} = {DD14191F-22CE-48D8-A944-B8A41C97ACD4}
|
{6E79742F-1E56-4B7D-94E8-B509D43561FA} = {DD14191F-22CE-48D8-A944-B8A41C97ACD4}
|
||||||
{729950F2-71EE-42C0-8B46-295740DE20BA} = {0C0B6EB5-E41D-46D9-9F60-90D320A2EEF3}
|
{729950F2-71EE-42C0-8B46-295740DE20BA} = {0C0B6EB5-E41D-46D9-9F60-90D320A2EEF3}
|
||||||
|
{48E1532F-8B50-477C-BB78-8AEA89A167CE} = {DD14191F-22CE-48D8-A944-B8A41C97ACD4}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {4A1DC406-AFAA-4884-859C-51B9B26E37FC}
|
SolutionGuid = {4A1DC406-AFAA-4884-859C-51B9B26E37FC}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\HuanMeng.DotNetCore\HuanMeng.DotNetCore.csproj" />
|
<ProjectReference Include="..\HuanMeng.DotNetCore\HuanMeng.DotNetCore.csproj" />
|
||||||
<ProjectReference Include="..\HuanMeng.MiaoYu.Model\HuanMeng.MiaoYu.Model.csproj" />
|
<ProjectReference Include="..\HuanMeng.MiaoYu.Model\HuanMeng.MiaoYu.Model.csproj" />
|
||||||
|
<ProjectReference Include="..\HuanMeng.Utility\HuanMeng.Utility.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
53
src/0-core/HuanMeng.Utility/AssemblyHelper/AssemblyInfo.cs
Normal file
53
src/0-core/HuanMeng.Utility/AssemblyHelper/AssemblyInfo.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace HuanMeng.Utility.AssemblyHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 保存各种程序集信息属性的类。
|
||||||
|
/// </summary>
|
||||||
|
public class AssemblyInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置程序集的版本。
|
||||||
|
/// </summary>
|
||||||
|
public string Version { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置程序集的文件版本。
|
||||||
|
/// </summary>
|
||||||
|
public string FileVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置程序集版本。
|
||||||
|
/// </summary>
|
||||||
|
public string AssemblyVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置程序集的信息性版本。
|
||||||
|
/// </summary>
|
||||||
|
public string InformationalVersion { get; set; }
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 获取或设置与程序集关联的公司名称。
|
||||||
|
///// </summary>
|
||||||
|
//public string Company { get; set; }
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 获取或设置与程序集关联的产品名称。
|
||||||
|
///// </summary>
|
||||||
|
//public string Product { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置与程序集关联的版权信息。
|
||||||
|
/// </summary>
|
||||||
|
public string Copyright { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置程序集的描述信息。
|
||||||
|
/// </summary>
|
||||||
|
public string Description { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace HuanMeng.Utility.AssemblyHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用于检索程序集信息的辅助类。
|
||||||
|
/// </summary>
|
||||||
|
public static class AssemblyInfoHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 从正在执行的程序集检索各种属性,并返回一个 AssemblyInfo 对象。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>包含程序集属性的 AssemblyInfo 对象。</returns>
|
||||||
|
public static AssemblyInfo GetAssemblyInfo()
|
||||||
|
{
|
||||||
|
// 获取正在执行的程序集
|
||||||
|
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||||
|
|
||||||
|
// 创建并填充 AssemblyInfo 对象的相关属性
|
||||||
|
var assemblyInfo = new AssemblyInfo
|
||||||
|
{
|
||||||
|
Version = assembly.GetCustomAttributes<AssemblyVersionAttribute>().FirstOrDefault()?.Version ?? "",
|
||||||
|
FileVersion = assembly.GetCustomAttributes<AssemblyFileVersionAttribute>().FirstOrDefault()?.Version ?? "",
|
||||||
|
AssemblyVersion = assembly.GetName().Version.ToString(),
|
||||||
|
InformationalVersion = assembly.GetCustomAttributes<AssemblyInformationalVersionAttribute>().FirstOrDefault()?.InformationalVersion ?? "",
|
||||||
|
//Company = assembly.GetCustomAttributes<AssemblyCompanyAttribute>().FirstOrDefault()?.Company ?? "",
|
||||||
|
//Product = assembly.GetCustomAttributes<AssemblyProductAttribute>().FirstOrDefault()?.Product ?? "",
|
||||||
|
Copyright = assembly.GetCustomAttributes<AssemblyCopyrightAttribute>().FirstOrDefault()?.Copyright ?? "",
|
||||||
|
Description = assembly.GetCustomAttributes<AssemblyDescriptionAttribute>().FirstOrDefault()?.Description ?? ""
|
||||||
|
};
|
||||||
|
|
||||||
|
return assemblyInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/0-core/HuanMeng.Utility/Class1.cs
Normal file
9
src/0-core/HuanMeng.Utility/Class1.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace HuanMeng.Utility
|
||||||
|
{
|
||||||
|
public class Class1
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
8
src/0-core/HuanMeng.Utility/HuanMeng.Utility.csproj
Normal file
8
src/0-core/HuanMeng.Utility/HuanMeng.Utility.csproj
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
<ProjectReference Include="..\..\0-core\HuanMeng.DotNetCore\HuanMeng.DotNetCore.csproj" />
|
<ProjectReference Include="..\..\0-core\HuanMeng.DotNetCore\HuanMeng.DotNetCore.csproj" />
|
||||||
<ProjectReference Include="..\..\0-core\HuanMeng.MiaoYu.Code\HuanMeng.MiaoYu.Code.csproj" />
|
<ProjectReference Include="..\..\0-core\HuanMeng.MiaoYu.Code\HuanMeng.MiaoYu.Code.csproj" />
|
||||||
<ProjectReference Include="..\..\0-core\HuanMeng.MiaoYu.Model\HuanMeng.MiaoYu.Model.csproj" />
|
<ProjectReference Include="..\..\0-core\HuanMeng.MiaoYu.Model\HuanMeng.MiaoYu.Model.csproj" />
|
||||||
|
<ProjectReference Include="..\..\0-core\HuanMeng.Utility\HuanMeng.Utility.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@ using HuanMeng.MiaoYu.Code.TencentUtile;
|
||||||
using HuanMeng.MiaoYu.Code.Users.UserAccount.VerificationCodeManager;
|
using HuanMeng.MiaoYu.Code.Users.UserAccount.VerificationCodeManager;
|
||||||
using HuanMeng.MiaoYu.Code.JwtUtil;
|
using HuanMeng.MiaoYu.Code.JwtUtil;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using HuanMeng.Utility.AssemblyHelper;
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
// 检索程序集信息
|
||||||
|
AssemblyInfo assemblyInfo = AssemblyInfoHelper.GetAssemblyInfo();
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddHttpContextAccessor(); //添加httpContext注入访问
|
builder.Services.AddHttpContextAccessor(); //添加httpContext注入访问
|
||||||
#region 添加跨域
|
#region 添加跨域
|
||||||
|
|
@ -57,7 +59,7 @@ builder.Services.AddSwaggerGen(c =>
|
||||||
{securityScheme, Array.Empty<string>()}
|
{securityScheme, Array.Empty<string>()}
|
||||||
});
|
});
|
||||||
|
|
||||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "妙语", Version = "v1" });
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = "妙语", Version = assemblyInfo.Version, Description = assemblyInfo.Description });
|
||||||
foreach (var assemblies in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (var assemblies in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
// 添加 XML 注释文件路径
|
// 添加 XML 注释文件路径
|
||||||
|
|
@ -112,7 +114,7 @@ app.UseExceptionMiddleware();
|
||||||
app.MapGet("/", () => "请求成功").WithName("默认请求");
|
app.MapGet("/", () => "请求成功").WithName("默认请求");
|
||||||
|
|
||||||
var startDateTime = DateTime.Now;
|
var startDateTime = DateTime.Now;
|
||||||
var InformationalVersion = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
//var InformationalVersion = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
||||||
//Console.WriteLine($"version:{InformationalVersion}");
|
//Console.WriteLine($"version:{InformationalVersion}");
|
||||||
app.MapGet("/system", () =>
|
app.MapGet("/system", () =>
|
||||||
{
|
{
|
||||||
|
|
@ -124,8 +126,8 @@ app.MapGet("/system", () =>
|
||||||
long memoryUsage = currentProcess.WorkingSet64;
|
long memoryUsage = currentProcess.WorkingSet64;
|
||||||
return new
|
return new
|
||||||
{
|
{
|
||||||
msg = $"系统版本:{InformationalVersion},启动时间:{startDateTime.ToString("yyyy-MM-dd HH:mm:ss")},已安全运行时间:{DateTime.Now.Subtract(startDateTime).TotalMinutes.ToString("#.##")}分钟",
|
msg = $"系统信息:{assemblyInfo.InformationalVersion},启动时间:{startDateTime.ToString("yyyy-MM-dd HH:mm:ss")},已安全运行时间:{DateTime.Now.Subtract(startDateTime).TotalMinutes.ToString("0.##")}分钟",
|
||||||
InformationalVersion,
|
assemblyInfo,
|
||||||
startDateTime,
|
startDateTime,
|
||||||
MemoryUsage = $"{memoryUsage / (1024.0 * 1024.0):F2}MB",
|
MemoryUsage = $"{memoryUsage / (1024.0 * 1024.0):F2}MB",
|
||||||
CPUUsage = $"{cpuUsage:F2}%"
|
CPUUsage = $"{cpuUsage:F2}%"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user