From 7fc5fca5d94bc9cf9d5f29c556d927530b673db6 Mon Sep 17 00:00:00 2001 From: nsnail Date: Wed, 13 Nov 2024 18:50:24 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=F0=9F=93=A6=20nuget=20package?= =?UTF-8?q?=E4=B8=8E=20project=20refrence=20=E5=88=87=E6=8D=A2=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=20(#199)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: tk --- NetAdmin.sln | 29 +++++++++++-- scripts/switch.nuget.or.project.csx | 42 +++++++++++++++++++ scripts/switcher.freesql.json | 22 ---------- scripts/switcher.gurion.json | 17 -------- scripts/switcher.nsext.json | 17 -------- scripts/switcher.ps1 | 27 ------------ .../Events/SeedDataInsertedEvent.cs | 6 +-- .../NetAdmin.Domain/Events/SqlCommandEvent.cs | 6 +-- .../NetAdmin.Infrastructure.csproj | 16 ++++--- .../Events/Sys/RequestLogEvent.cs | 6 +-- .../Events/Sys/UserCreatedEvent.cs | 6 +-- .../Events/Sys/UserUpdatedEvent.cs | 6 +-- .../Events/Sys/VerifyCodeCreatedEvent.cs | 6 +-- .../NetAdmin.Tests/NetAdmin.Tests.csproj | 2 +- 14 files changed, 97 insertions(+), 111 deletions(-) create mode 100644 scripts/switch.nuget.or.project.csx delete mode 100644 scripts/switcher.freesql.json delete mode 100644 scripts/switcher.gurion.json delete mode 100644 scripts/switcher.nsext.json delete mode 100644 scripts/switcher.ps1 diff --git a/NetAdmin.sln b/NetAdmin.sln index bb75d795..bed18497 100644 --- a/NetAdmin.sln +++ b/NetAdmin.sln @@ -44,10 +44,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{BB0B install.as.tpl.ps1 = scripts/install.as.tpl.ps1 rename.csx = scripts/rename.csx resharper.full.ps1 = scripts/resharper.full.ps1 - switcher.freesql.json = scripts/switcher.freesql.json - switcher.gurion.json = scripts/switcher.gurion.json - switcher.nsext.json = scripts/switcher.nsext.json - switcher.ps1 = scripts/switcher.ps1 + switch.nuget.or.project.csx = scripts/switch.nuget.or.project.csx sync.sln.files.csx = scripts/sync.sln.files.csx wait.server.stop.sh = scripts/wait.server.stop.sh EndProjectSection @@ -119,6 +116,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YourSolution.AdmServer.Infr EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetAdmin.SysComponent.Infrastructure", "src\backend\NetAdmin\NetAdmin.SysComponent.Infrastructure\NetAdmin.SysComponent.Infrastructure.csproj", "{48EE6FC4-B64A-40D3-B889-36837E067880}" EndProject +##Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gurion", "refs\Gurion\src\Gurion\Gurion.csproj", "{CCD098FE-4F95-4FA4-8CC0-9A6DE921FBAE}"#refs +##EndProject#refs +##Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeSql", "refs\FreeSql\FreeSql\FreeSql.csproj", "{3C65DA42-877D-46FF-B754-C12214302A29}"#refs +##EndProject#refs +##Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeSql.Provider.Sqlite", "refs\FreeSql\Providers\FreeSql.Provider.Sqlite\FreeSql.Provider.Sqlite.csproj", "{CF5EFA63-4631-4A64-B4F3-98A7DD532F68}"#refs +##EndProject#refs +##Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeSql.DbContext", "refs\FreeSql\FreeSql.DbContext\FreeSql.DbContext.csproj", "{FE03DF27-EC56-48DB-81B0-F99947259A7C}"#refs +##EndProject#refs Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -196,6 +201,22 @@ Global {48EE6FC4-B64A-40D3-B889-36837E067880}.Debug|Any CPU.Build.0 = Debug|Any CPU {48EE6FC4-B64A-40D3-B889-36837E067880}.Release|Any CPU.ActiveCfg = Release|Any CPU {48EE6FC4-B64A-40D3-B889-36837E067880}.Release|Any CPU.Build.0 = Release|Any CPU + ##{CCD098FE-4F95-4FA4-8CC0-9A6DE921FBAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + ##{CCD098FE-4F95-4FA4-8CC0-9A6DE921FBAE}.Debug|Any CPU.Build.0 = Debug|Any CPU + ##{CCD098FE-4F95-4FA4-8CC0-9A6DE921FBAE}.Release|Any CPU.ActiveCfg = Release|Any CPU + ##{CCD098FE-4F95-4FA4-8CC0-9A6DE921FBAE}.Release|Any CPU.Build.0 = Release|Any CPU + ##{3C65DA42-877D-46FF-B754-C12214302A29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + ##{3C65DA42-877D-46FF-B754-C12214302A29}.Debug|Any CPU.Build.0 = Debug|Any CPU + ##{3C65DA42-877D-46FF-B754-C12214302A29}.Release|Any CPU.ActiveCfg = Release|Any CPU + ##{3C65DA42-877D-46FF-B754-C12214302A29}.Release|Any CPU.Build.0 = Release|Any CPU + ##{CF5EFA63-4631-4A64-B4F3-98A7DD532F68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + ##{CF5EFA63-4631-4A64-B4F3-98A7DD532F68}.Debug|Any CPU.Build.0 = Debug|Any CPU + ##{CF5EFA63-4631-4A64-B4F3-98A7DD532F68}.Release|Any CPU.ActiveCfg = Release|Any CPU + ##{CF5EFA63-4631-4A64-B4F3-98A7DD532F68}.Release|Any CPU.Build.0 = Release|Any CPU + ##{FE03DF27-EC56-48DB-81B0-F99947259A7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + ##{FE03DF27-EC56-48DB-81B0-F99947259A7C}.Debug|Any CPU.Build.0 = Debug|Any CPU + ##{FE03DF27-EC56-48DB-81B0-F99947259A7C}.Release|Any CPU.ActiveCfg = Release|Any CPU + ##{FE03DF27-EC56-48DB-81B0-F99947259A7C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {4DAF9366-855F-46BB-AE4C-660C92FA0697} = {C84EB5A0-37AD-4B17-A51E-E36888C4441E} diff --git a/scripts/switch.nuget.or.project.csx b/scripts/switch.nuget.or.project.csx new file mode 100644 index 00000000..57ad4290 --- /dev/null +++ b/scripts/switch.nuget.or.project.csx @@ -0,0 +1,42 @@ +using System.Text.RegularExpressions; +string input = string.Empty; +while (!new[] { "1", "2" }.Contains(input)) +{ + Console.WriteLine("1.nuget 2.project"); + input = Console.ReadLine(); +} +var slnFile = Directory.GetFiles(@"../", "*.sln").First(); +var csprojFiles = Directory.GetFiles(@"../src", "*.csproj", new EnumerationOptions { RecurseSubdirectories = true }); +var slnContent = File.ReadAllText(slnFile); + +if (input == "1") +{ + slnContent = Regex.Replace(slnContent, "\\nProject\\((.*)#refs", "\n##Project($1#refs"); + slnContent = Regex.Replace(slnContent, "\\nEndProject#refs", "\n##EndProject#refs"); + foreach (Match m in Regex.Matches(slnContent, "\"(\\{[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}\\})\"#refs")) + { + slnContent = slnContent.Replace($" {m.Groups[1].Value}.", $" ##{m.Groups[1].Value}."); + } + foreach (var csprojFile in csprojFiles) + { + var csprojContent = File.ReadAllText(csprojFile); + csprojContent = Regex.Replace(csprojContent," ", " "); + csprojContent = Regex.Replace(csprojContent," ", " "); + File.WriteAllText(csprojFile, csprojContent); + } +} +else +{ + slnContent = Regex.Replace(slnContent, "##", ""); + foreach (var csprojFile in csprojFiles) + { + var csprojContent = File.ReadAllText(csprojFile); + csprojContent = Regex.Replace(csprojContent," ", " "); + csprojContent = Regex.Replace(csprojContent," ", " "); + File.WriteAllText(csprojFile, csprojContent); + } +} + + +Console.WriteLine(slnContent); +File.WriteAllText(slnFile, slnContent); \ No newline at end of file diff --git a/scripts/switcher.freesql.json b/scripts/switcher.freesql.json deleted file mode 100644 index 3390871b..00000000 --- a/scripts/switcher.freesql.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "solution": "NetAdmin.sln", - "mappings": { - "FreeSql.NS": "../refs/FreeSql/FreeSql/FreeSql.csproj", - "FreeSql.DbContext.NS": "../refs/FreeSql/FreeSql.DbContext/FreeSql.DbContext.csproj" - }, - "restore": [ - { - "name": "NetAdmin.Infrastructure", - "packages": [ - { - "packageName": "FreeSql.NS", - "version": "3.2.833-ns4" - }, - { - "packageName": "FreeSql.DbContext.NS", - "version": "3.2.833-ns4" - } - ] - } - ] -} \ No newline at end of file diff --git a/scripts/switcher.gurion.json b/scripts/switcher.gurion.json deleted file mode 100644 index 3ec2b573..00000000 --- a/scripts/switcher.gurion.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "solution": "NetAdmin.sln", - "mappings": { - "Gurion": "../refs/Gurion/src/Gurion.csproj" - }, - "restore": [ - { - "name": "NetAdmin.Infrastructure", - "packages": [ - { - "packageName": "Gurion", - "version": "1.1.0" - } - ] - } - ] -} \ No newline at end of file diff --git a/scripts/switcher.nsext.json b/scripts/switcher.nsext.json deleted file mode 100644 index 301f0370..00000000 --- a/scripts/switcher.nsext.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "solution": "NetAdmin.sln", - "mappings": { - "NSExt": "../refs/ns-ext/src/NSExt/NSExt.csproj" - }, - "restore": [ - { - "name": "NetAdmin.Infrastructure", - "packages": [ - { - "packageName": "NSExt", - "version": "2.2.0" - } - ] - } - ] -} \ No newline at end of file diff --git a/scripts/switcher.ps1 b/scripts/switcher.ps1 deleted file mode 100644 index b4f83e3e..00000000 --- a/scripts/switcher.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -# https://github.com/RicoSuter/DNT#switch-to-projects -$targets = @{ - '1' = 'switch-to-projects' - '2' = 'switch-to-packages' -} -$key = '' -while ($null -eq $targets[$key]) -{ - $key = Read-Host '请选择:1(切换到项目引用) 2(切换到Nuget包引用)' -} -$files = Get-ChildItem Switcher.*.json -$file = 9999 -while ($null -eq $files[[int]$file - 1]) -{ - $i = 0 - Write-Host '请选择要切换的配置文件文件' - foreach ($file in $files) - { - $i++ - Write-Host $i $file.Name - } - $file = Read-Host -} -$file = [int]$file - 1 -Copy-Item $files[$file] 'switcher.json' -Force -dnt $targets[$key] ../NetAdmin.sln -Remove-Item switcher.json \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Events/SeedDataInsertedEvent.cs b/src/backend/NetAdmin/NetAdmin.Domain/Events/SeedDataInsertedEvent.cs index fe9ea3e2..50abdc2b 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Events/SeedDataInsertedEvent.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Events/SeedDataInsertedEvent.cs @@ -8,9 +8,9 @@ public sealed record SeedDataInsertedEvent : DataAbstraction, IEventSource /// /// Initializes a new instance of the class. /// - public SeedDataInsertedEvent(int insertedCount, bool isConsumOnce = false) + public SeedDataInsertedEvent(int insertedCount, bool isConsumeOnce = false) { - IsConsumOnce = isConsumOnce; + IsConsumeOnce = isConsumeOnce; InsertedCount = insertedCount; CreatedTime = DateTime.Now; EventId = nameof(SeedDataInsertedEvent); @@ -23,7 +23,7 @@ public sealed record SeedDataInsertedEvent : DataAbstraction, IEventSource public string EventId { get; } /// - public bool IsConsumOnce { get; } + public bool IsConsumeOnce { get; } /// public CancellationToken CancellationToken { get; init; } diff --git a/src/backend/NetAdmin/NetAdmin.Domain/Events/SqlCommandEvent.cs b/src/backend/NetAdmin/NetAdmin.Domain/Events/SqlCommandEvent.cs index 88a877a7..8d2c6e73 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/Events/SqlCommandEvent.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/Events/SqlCommandEvent.cs @@ -8,13 +8,13 @@ public abstract record SqlCommandEvent : DataAbstraction, IEventSource /// /// Initializes a new instance of the class. /// - protected SqlCommandEvent(bool isConsumOnce = false) + protected SqlCommandEvent(bool isConsumeOnce = false) { - IsConsumOnce = isConsumOnce; + IsConsumeOnce = isConsumeOnce; } /// - public bool IsConsumOnce { get; } + public bool IsConsumeOnce { get; } /// public CancellationToken CancellationToken { get; init; } diff --git a/src/backend/NetAdmin/NetAdmin.Infrastructure/NetAdmin.Infrastructure.csproj b/src/backend/NetAdmin/NetAdmin.Infrastructure/NetAdmin.Infrastructure.csproj index 18fe7cf0..5e0c396a 100644 --- a/src/backend/NetAdmin/NetAdmin.Infrastructure/NetAdmin.Infrastructure.csproj +++ b/src/backend/NetAdmin/NetAdmin.Infrastructure/NetAdmin.Infrastructure.csproj @@ -3,15 +3,21 @@ - - - + + + - + - + + + + + + + diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/RequestLogEvent.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/RequestLogEvent.cs index cf0db030..8123c5cd 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/RequestLogEvent.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/RequestLogEvent.cs @@ -11,11 +11,11 @@ public sealed record RequestLogEvent : DataAbstraction, IEventSourceGeneric /// Initializes a new instance of the class. /// - public RequestLogEvent(CreateRequestLogReq data, bool isConsumOnce = false, object payload = default, DateTime createdTime = default + public RequestLogEvent(CreateRequestLogReq data, bool isConsumeOnce = false, object payload = default, DateTime createdTime = default , CancellationToken cancellationToken = default) { Data = data; - IsConsumOnce = isConsumOnce; + IsConsumeOnce = isConsumeOnce; Payload = payload; CreatedTime = createdTime; CancellationToken = cancellationToken; @@ -34,7 +34,7 @@ public sealed record RequestLogEvent : DataAbstraction, IEventSourceGeneric nameof(RequestLogEvent); /// - public bool IsConsumOnce { get; } + public bool IsConsumeOnce { get; } /// public object Payload { get; } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/UserCreatedEvent.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/UserCreatedEvent.cs index b2953f78..9750940f 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/UserCreatedEvent.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/UserCreatedEvent.cs @@ -11,13 +11,13 @@ public sealed record UserCreatedEvent : DataAbstraction, IEventSourceGeneric /// Initializes a new instance of the class. /// - public UserCreatedEvent(UserInfoRsp data, DateTime createdTime = default, bool isConsumOnce = false, object payload = default + public UserCreatedEvent(UserInfoRsp data, DateTime createdTime = default, bool isConsumeOnce = false, object payload = default , CancellationToken cancellationToken = default) { Data = data; CancellationToken = cancellationToken; CreatedTime = createdTime; - IsConsumOnce = isConsumOnce; + IsConsumeOnce = isConsumeOnce; Payload = payload; } @@ -34,7 +34,7 @@ public sealed record UserCreatedEvent : DataAbstraction, IEventSourceGeneric nameof(UserCreatedEvent); /// - public bool IsConsumOnce { get; } + public bool IsConsumeOnce { get; } /// public object Payload { get; } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/UserUpdatedEvent.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/UserUpdatedEvent.cs index ae45dfb9..6fa4b6bb 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/UserUpdatedEvent.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/UserUpdatedEvent.cs @@ -11,13 +11,13 @@ public sealed record UserUpdatedEvent : DataAbstraction, IEventSourceGeneric /// Initializes a new instance of the class. /// - public UserUpdatedEvent(UserInfoRsp data, DateTime createdTime = default, bool isConsumOnce = false, object payload = default + public UserUpdatedEvent(UserInfoRsp data, DateTime createdTime = default, bool isConsumeOnce = false, object payload = default , CancellationToken cancellationToken = default) { Data = data; CancellationToken = cancellationToken; CreatedTime = createdTime; - IsConsumOnce = isConsumOnce; + IsConsumeOnce = isConsumeOnce; Payload = payload; } @@ -34,7 +34,7 @@ public sealed record UserUpdatedEvent : DataAbstraction, IEventSourceGeneric nameof(UserUpdatedEvent); /// - public bool IsConsumOnce { get; } + public bool IsConsumeOnce { get; } /// public object Payload { get; } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/VerifyCodeCreatedEvent.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/VerifyCodeCreatedEvent.cs index 0e6c4650..6b86bd14 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/VerifyCodeCreatedEvent.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Domain/Events/Sys/VerifyCodeCreatedEvent.cs @@ -11,13 +11,13 @@ public sealed record VerifyCodeCreatedEvent : DataAbstraction, IEventSourceGener /// /// Initializes a new instance of the class. /// - public VerifyCodeCreatedEvent(QueryVerifyCodeRsp data, DateTime createdTime = default, bool isConsumOnce = false, object payload = default + public VerifyCodeCreatedEvent(QueryVerifyCodeRsp data, DateTime createdTime = default, bool isConsumeOnce = false, object payload = default , CancellationToken cancellationToken = default) { Data = data; CancellationToken = cancellationToken; CreatedTime = createdTime; - IsConsumOnce = isConsumOnce; + IsConsumeOnce = isConsumeOnce; Payload = payload; } @@ -34,7 +34,7 @@ public sealed record VerifyCodeCreatedEvent : DataAbstraction, IEventSourceGener public string EventId => nameof(VerifyCodeCreatedEvent); /// - public bool IsConsumOnce { get; } + public bool IsConsumeOnce { get; } /// public object Payload { get; } diff --git a/src/backend/NetAdmin/NetAdmin.Tests/NetAdmin.Tests.csproj b/src/backend/NetAdmin/NetAdmin.Tests/NetAdmin.Tests.csproj index c9bab2c2..ff527654 100644 --- a/src/backend/NetAdmin/NetAdmin.Tests/NetAdmin.Tests.csproj +++ b/src/backend/NetAdmin/NetAdmin.Tests/NetAdmin.Tests.csproj @@ -3,7 +3,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive