build: 📦 nuget package与 project refrence 切换脚本 (#199)

Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
nsnail 2024-11-13 18:50:24 +08:00 committed by GitHub
parent d8dbb28cfc
commit 7fc5fca5d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 97 additions and 111 deletions

View File

@ -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}

View File

@ -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," <ProjectReference(.*)Label=\"refs\"(.*)>", " <!--<ProjectReference$1Label=\"refs\"$2>-->");
csprojContent = Regex.Replace(csprojContent," <!--<PackageReference(.*)Label=\"refs\"(.*)>-->", " <PackageReference$1Label=\"refs\"$2>");
File.WriteAllText(csprojFile, csprojContent);
}
}
else
{
slnContent = Regex.Replace(slnContent, "##", "");
foreach (var csprojFile in csprojFiles)
{
var csprojContent = File.ReadAllText(csprojFile);
csprojContent = Regex.Replace(csprojContent," <!--<ProjectReference(.*)Label=\"refs\"(.*)>-->", " <ProjectReference$1Label=\"refs\"$2>");
csprojContent = Regex.Replace(csprojContent," <PackageReference(.*)Label=\"refs\"(.*)>", " <!--<PackageReference$1Label=\"refs\"$2>-->");
File.WriteAllText(csprojFile, csprojContent);
}
}
Console.WriteLine(slnContent);
File.WriteAllText(slnFile, slnContent);

View File

@ -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"
}
]
}
]
}

View File

@ -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"
}
]
}
]
}

View File

@ -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"
}
]
}
]
}

View File

@ -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

View File

@ -8,9 +8,9 @@ public sealed record SeedDataInsertedEvent : DataAbstraction, IEventSource
/// <summary>
/// Initializes a new instance of the <see cref="SeedDataInsertedEvent" /> class.
/// </summary>
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; }
/// <inheritdoc />
public bool IsConsumOnce { get; }
public bool IsConsumeOnce { get; }
/// <inheritdoc />
public CancellationToken CancellationToken { get; init; }

View File

@ -8,13 +8,13 @@ public abstract record SqlCommandEvent : DataAbstraction, IEventSource
/// <summary>
/// Initializes a new instance of the <see cref="SqlCommandEvent" /> class.
/// </summary>
protected SqlCommandEvent(bool isConsumOnce = false)
protected SqlCommandEvent(bool isConsumeOnce = false)
{
IsConsumOnce = isConsumOnce;
IsConsumeOnce = isConsumeOnce;
}
/// <inheritdoc />
public bool IsConsumOnce { get; }
public bool IsConsumeOnce { get; }
/// <inheritdoc />
public CancellationToken CancellationToken { get; init; }

View File

@ -3,15 +3,21 @@
<Import Project="$(SolutionDir)/build/copy.pkg.xml.comment.files.targets"/>
<Import Project="$(SolutionDir)/build/prebuild.targets"/>
<ItemGroup>
<PackageReference Include="FreeSql.DbContext.NS" Version="3.2.833-ns4"/>
<PackageReference Include="FreeSql.Provider.Sqlite.NS" Version="3.2.833-ns4"/>
<PackageReference Include="Gurion" Version="1.2.0"/>
<PackageReference Include="FreeSql.DbContext.NS" Version="3.2.833-ns5" Label="refs"/>
<PackageReference Include="FreeSql.Provider.Sqlite.NS" Version="3.2.833-ns5" Label="refs"/>
<PackageReference Include="Gurion" Version="1.2.1" Label="refs"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.12.0-3.final"/>
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0-rc.2.24474.3"/>
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0"/>
<PackageReference Include="Minio" Version="6.0.3"/>
<PackageReference Include="NSExt" Version="2.2.0"/>
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.4"/>
<PackageReference Include="System.Drawing.Common" Version="9.0.0-rc.2.24474.1"/>
<PackageReference Include="System.Drawing.Common" Version="9.0.0"/>
</ItemGroup>
<ItemGroup>
<!--<ProjectReference Include="$(SolutionDir)/refs/FreeSql/FreeSql.DbContext/FreeSql.DbContext.csproj" Label="refs"/>-->
<!--<ProjectReference Include="$(SolutionDir)/refs/FreeSql/FreeSql/FreeSql.csproj" Label="refs"/>-->
<!--<ProjectReference Include="$(SolutionDir)/refs/FreeSql/Providers/FreeSql.Provider.Sqlite/FreeSql.Provider.Sqlite.csproj" Label="refs"/>-->
<!--<ProjectReference Include="$(SolutionDir)/refs/Gurion/src/Gurion/Gurion.csproj" Label="refs"/>-->
</ItemGroup>
<ItemGroup>
<None Include="$(SolutionDir)/assets/res/NetAdmin.Statements.ln">

View File

@ -11,11 +11,11 @@ public sealed record RequestLogEvent : DataAbstraction, IEventSourceGeneric<Crea
/// <summary>
/// Initializes a new instance of the <see cref="RequestLogEvent" /> class.
/// </summary>
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<Crea
public string EventId => nameof(RequestLogEvent);
/// <inheritdoc />
public bool IsConsumOnce { get; }
public bool IsConsumeOnce { get; }
/// <inheritdoc />
public object Payload { get; }

View File

@ -11,13 +11,13 @@ public sealed record UserCreatedEvent : DataAbstraction, IEventSourceGeneric<Use
/// <summary>
/// Initializes a new instance of the <see cref="UserCreatedEvent" /> class.
/// </summary>
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<Use
public string EventId => nameof(UserCreatedEvent);
/// <inheritdoc />
public bool IsConsumOnce { get; }
public bool IsConsumeOnce { get; }
/// <inheritdoc />
public object Payload { get; }

View File

@ -11,13 +11,13 @@ public sealed record UserUpdatedEvent : DataAbstraction, IEventSourceGeneric<Use
/// <summary>
/// Initializes a new instance of the <see cref="UserUpdatedEvent" /> class.
/// </summary>
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<Use
public string EventId => nameof(UserUpdatedEvent);
/// <inheritdoc />
public bool IsConsumOnce { get; }
public bool IsConsumeOnce { get; }
/// <inheritdoc />
public object Payload { get; }

View File

@ -11,13 +11,13 @@ public sealed record VerifyCodeCreatedEvent : DataAbstraction, IEventSourceGener
/// <summary>
/// Initializes a new instance of the <see cref="VerifyCodeCreatedEvent" /> class.
/// </summary>
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);
/// <inheritdoc />
public bool IsConsumOnce { get; }
public bool IsConsumeOnce { get; }
/// <inheritdoc />
public object Payload { get; }

View File

@ -3,7 +3,7 @@
<ProjectReference Include="../NetAdmin.Host/NetAdmin.Host.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0-rc.2.24474.3"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0"/>
<PackageReference Include="xunit" Version="2.9.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0-pre.49">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>