Skip to content

Commit a9ce43e

Browse files
committed
Upgrade to .NET 9 and improve patch handling
Updated project files to target .NET 9 and enabled AOT publishing. Improved patch logic by adding PatchEnabled context and handling null checks in upgrade validation. Added Microsoft.Bcl.AsyncInterfaces package and refined decompression path selection based on patch status.
1 parent f6082e4 commit a9ce43e

File tree

7 files changed

+15
-11
lines changed

7 files changed

+15
-11
lines changed

src/c#/GeneralUpdate.Client/GeneralUpdate.Client.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<LangVersion>default</LangVersion>
9+
<PublishAot>true</PublishAot>
910
</PropertyGroup>
1011

1112
<ItemGroup>

src/c#/GeneralUpdate.Client/Program.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ static async Task Main(string[] args)
1616
{
1717
try
1818
{
19-
/*GeneralTracer.Info("Starting client");
20-
GeneralTracer.Error("test error");
21-
GeneralTracer.Debug("test debug");
22-
GeneralTracer.SetTracingEnabled(false);
23-
GeneralTracer.Dispose();*/
24-
2519
Console.WriteLine($"主程序初始化,{DateTime.Now}!");
2620
Console.WriteLine("当前运行目录:" + Thread.GetDomain().BaseDirectory);
2721
await Task.Delay(2000);

src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,15 @@ private bool CheckFail(string version)
306306
/// <returns></returns>
307307
private bool CheckUpgrade(VersionRespDTO? response)
308308
{
309-
if (response == null)
309+
if (response is null)
310310
return false;
311311

312+
if (response.Body is null)
313+
return false;
314+
312315
if (response.Code == 200)
313316
return response.Body.Count > 0;
314-
317+
315318
return false;
316319
}
317320

src/c#/GeneralUpdate.ClientCore/GeneralUpdate.ClientCore.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787

8888
<ItemGroup>
8989
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.0" />
90+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0" />
9091
<PackageReference Include="System.Collections.Immutable" Version="9.0.0" />
9192
<PackageReference Include="System.Net.Http" Version="4.3.4" />
9293
<PackageReference Include="System.Net.Requests" Version="4.3.0" />

src/c#/GeneralUpdate.ClientCore/Pipeline/CompressMiddleware.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ public Task InvokeAsync(PipelineContext? context)
2020
var sourcePath = context.Get<string>("ZipFilePath");
2121
var patchPath = context.Get<string>("PatchPath");
2222
var encoding = context.Get<Encoding>("Encoding");
23-
CompressProvider.Decompress(format,sourcePath,patchPath, encoding);
23+
var appPath = context.Get<string>("SourcePath");
24+
var patchEnabled = context.Get<bool?>("PatchEnabled");
25+
26+
CompressProvider.Decompress(format, sourcePath,patchEnabled == false ? appPath : patchPath, encoding);
2427
});
2528
}
2629
}

src/c#/GeneralUpdate.ClientCore/Strategys/WindowsStrategy.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public override async Task ExecuteAsync()
4848
//patch middleware
4949
context.Add("SourcePath", _configinfo.InstallPath);
5050
context.Add("PatchPath", patchPath);
51+
context.Add("PatchEnabled", _configinfo.PatchEnabled);
5152

5253
var pipelineBuilder = new PipelineBuilder(context)
5354
.UseMiddlewareIf<PatchMiddleware>(_configinfo.PatchEnabled)

src/c#/GeneralUpdate.Upgrad/GeneralUpdate.Upgrad.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<PublishAot>true</PublishAot>
99
<LangVersion>default</LangVersion>
10+
<PublishAot>true</PublishAot>
1011
</PropertyGroup>
1112

1213
<ItemGroup>

0 commit comments

Comments
 (0)