From 28c0321b084e5eee56fbb9c4efd61daa4dc2a632 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 13:01:48 +0000
Subject: [PATCH 1/5] Initial plan
From 94a1a8239399f9a0d626a51789bc913802e8427d Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 13:08:13 +0000
Subject: [PATCH 2/5] Add driver update functionality to GeneralUpdate.Core
- Added multi-target framework support (netstandard2.0 and net8.0) to GeneralUpdate.Core
- Added ProjectReference to GeneralUpdate.Drivelution for net8.0 target
- Added DriverDirectory field to GlobalConfigInfo for specifying driver file location
- Created DrivelutionMiddleware to integrate driver update functionality
- Updated WindowsStrategy and LinuxStrategy to support driver updates
- DrivelutionMiddleware retrieves drivers from directory and calls QuickUpdateAsync for installation
- Used conditional compilation to ensure driver update features only available in net8.0 target
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Shared/Object/GlobalConfigInfo.cs | 6 ++
.../GeneralUpdate.Core.csproj | 5 +-
.../Pipeline/DrivelutionMiddleware.cs | 100 ++++++++++++++++++
.../Strategys/LinuxStrategy.cs | 8 +-
.../Strategys/WindowsStrategy.cs | 8 +-
5 files changed, 122 insertions(+), 5 deletions(-)
create mode 100644 src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs
diff --git a/src/c#/GeneralUpdate.Common/Shared/Object/GlobalConfigInfo.cs b/src/c#/GeneralUpdate.Common/Shared/Object/GlobalConfigInfo.cs
index 62c6d0f3..5d0ce974 100644
--- a/src/c#/GeneralUpdate.Common/Shared/Object/GlobalConfigInfo.cs
+++ b/src/c#/GeneralUpdate.Common/Shared/Object/GlobalConfigInfo.cs
@@ -100,6 +100,12 @@ public class GlobalConfigInfo : BaseConfigInfo
///
public bool? DriveEnabled { get; set; }
+ ///
+ /// Directory path containing driver files for update.
+ /// Used when DriveEnabled is true to locate driver files for installation.
+ ///
+ public string DriverDirectory { get; set; }
+
///
/// Indicates whether differential patch update is enabled.
/// Computed from UpdateOption.Patch or defaults to true.
diff --git a/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj b/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj
index 1bc304aa..0a61943a 100644
--- a/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj
+++ b/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj
@@ -22,7 +22,7 @@
public
upgrade,update
true
- netstandard2.0;
+ netstandard2.0;net8.0
@@ -90,6 +90,9 @@
+
+
+
diff --git a/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs b/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs
new file mode 100644
index 00000000..6bb6b219
--- /dev/null
+++ b/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs
@@ -0,0 +1,100 @@
+#if NET8_0_OR_GREATER
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using GeneralUpdate.Common.Internal.Pipeline;
+using GeneralUpdate.Common.Shared;
+using GeneralUpdate.Drivelution;
+using GeneralUpdate.Drivelution.Abstractions.Models;
+
+namespace GeneralUpdate.Core.Pipeline;
+
+///
+/// Middleware for handling driver updates using GeneralUpdate.Drivelution functionality.
+///
+public class DrivelutionMiddleware : IMiddleware
+{
+ [RequiresUnreferencedCode("Driver update process includes signature validation that may require runtime reflection on some platforms")]
+ [RequiresDynamicCode("Driver update process includes signature validation that may require runtime code generation on some platforms")]
+ public async Task InvokeAsync(PipelineContext context)
+ {
+ try
+ {
+ var driverDirectory = context.Get("DriverDirectory");
+
+ if (string.IsNullOrWhiteSpace(driverDirectory))
+ {
+ GeneralTracer.Info("Driver directory not specified in context, skipping driver update.");
+ return;
+ }
+
+ if (!Directory.Exists(driverDirectory))
+ {
+ GeneralTracer.Info($"Driver directory does not exist: {driverDirectory}, skipping driver update.");
+ return;
+ }
+
+ GeneralTracer.Info($"Starting driver update from directory: {driverDirectory}");
+
+ // Get drivers from the specified directory
+ var drivers = await GeneralDrivelution.GetDriversFromDirectoryAsync(driverDirectory);
+
+ if (drivers == null || !drivers.Any())
+ {
+ GeneralTracer.Info($"No drivers found in directory: {driverDirectory}");
+ return;
+ }
+
+ GeneralTracer.Info($"Found {drivers.Count} driver(s) in directory.");
+
+ // Update each driver
+ var successCount = 0;
+ var failureCount = 0;
+ var results = new List();
+
+ foreach (var driver in drivers)
+ {
+ try
+ {
+ GeneralTracer.Info($"Updating driver: {driver.Name} (Version: {driver.Version})");
+
+ var result = await GeneralDrivelution.QuickUpdateAsync(driver);
+ results.Add(result);
+
+ if (result.Success)
+ {
+ successCount++;
+ GeneralTracer.Info($"Driver {driver.Name} updated successfully. Status: {result.Status}");
+ }
+ else
+ {
+ failureCount++;
+ var errorMessage = result.Error != null
+ ? $"{result.Error.Code}: {result.Error.Message}"
+ : "Unknown error";
+ GeneralTracer.Warn($"Driver {driver.Name} update failed. Error: {errorMessage}");
+ }
+ }
+ catch (Exception ex)
+ {
+ failureCount++;
+ GeneralTracer.Error($"Exception while updating driver {driver.Name}", ex);
+ }
+ }
+
+ GeneralTracer.Info($"Driver update completed. Success: {successCount}, Failed: {failureCount}");
+
+ // Store results in context for potential later use
+ context.Add("DriverUpdateResults", results);
+ }
+ catch (Exception ex)
+ {
+ GeneralTracer.Error("Error in DrivelutionMiddleware", ex);
+ throw;
+ }
+ }
+}
+#endif
diff --git a/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs
index 9de91fb7..13f32af5 100644
--- a/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs
+++ b/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs
@@ -21,7 +21,7 @@ protected override PipelineContext CreatePipelineContext(VersionInfo version, st
// Driver middleware (Linux-specific)
if (_configinfo.DriveEnabled == true)
{
- context.Add("DriverOutPut", StorageManager.GetTempDirectory("DriverOutPut"));
+ context.Add("DriverDirectory", _configinfo.DriverDirectory);
context.Add("FieldMappings", _configinfo.FieldMappings);
}
@@ -30,10 +30,14 @@ protected override PipelineContext CreatePipelineContext(VersionInfo version, st
protected override PipelineBuilder BuildPipeline(PipelineContext context)
{
- return new PipelineBuilder(context)
+ var builder = new PipelineBuilder(context)
.UseMiddlewareIf(_configinfo.PatchEnabled)
.UseMiddleware()
.UseMiddleware();
+#if NET8_0_OR_GREATER
+ builder.UseMiddlewareIf(_configinfo.DriveEnabled == true);
+#endif
+ return builder;
}
public override void Execute()
diff --git a/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs
index 78540f05..5c2abf55 100644
--- a/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs
+++ b/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs
@@ -23,7 +23,7 @@ protected override PipelineContext CreatePipelineContext(VersionInfo version, st
// Driver middleware (Windows-specific)
if (_configinfo.DriveEnabled == true)
{
- context.Add("DriverOutPut", StorageManager.GetTempDirectory("DriverOutPut"));
+ context.Add("DriverDirectory", _configinfo.DriverDirectory);
context.Add("FieldMappings", _configinfo.FieldMappings);
}
@@ -32,10 +32,14 @@ protected override PipelineContext CreatePipelineContext(VersionInfo version, st
protected override PipelineBuilder BuildPipeline(PipelineContext context)
{
- return new PipelineBuilder(context)
+ var builder = new PipelineBuilder(context)
.UseMiddlewareIf(_configinfo.PatchEnabled)
.UseMiddleware()
.UseMiddleware();
+#if NET8_0_OR_GREATER
+ builder.UseMiddlewareIf(_configinfo.DriveEnabled == true);
+#endif
+ return builder;
}
protected override void OnExecuteComplete()
From 3d7c49626fe70164e7e486181c9088adebed3424 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 13:11:42 +0000
Subject: [PATCH 3/5] Improve error message in DrivelutionMiddleware for better
debugging
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs b/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs
index 6bb6b219..cfcb4fac 100644
--- a/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs
+++ b/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs
@@ -92,7 +92,7 @@ public async Task InvokeAsync(PipelineContext context)
}
catch (Exception ex)
{
- GeneralTracer.Error("Error in DrivelutionMiddleware", ex);
+ GeneralTracer.Error($"Error in DrivelutionMiddleware while processing directory '{context.Get("DriverDirectory")}'", ex);
throw;
}
}
From 9807cec6eb62396ddda49cba19a9bca324e68fa4 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 13:25:43 +0000
Subject: [PATCH 4/5] Remove FieldMappings from pipeline context as it's no
longer required
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs | 1 -
src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs | 1 -
2 files changed, 2 deletions(-)
diff --git a/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs
index 13f32af5..751453e1 100644
--- a/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs
+++ b/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs
@@ -22,7 +22,6 @@ protected override PipelineContext CreatePipelineContext(VersionInfo version, st
if (_configinfo.DriveEnabled == true)
{
context.Add("DriverDirectory", _configinfo.DriverDirectory);
- context.Add("FieldMappings", _configinfo.FieldMappings);
}
return context;
diff --git a/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs
index 5c2abf55..0169a5bf 100644
--- a/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs
+++ b/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs
@@ -24,7 +24,6 @@ protected override PipelineContext CreatePipelineContext(VersionInfo version, st
if (_configinfo.DriveEnabled == true)
{
context.Add("DriverDirectory", _configinfo.DriverDirectory);
- context.Add("FieldMappings", _configinfo.FieldMappings);
}
return context;
From a7ea9f2d0776ab35855fdf48e6191680abd9f717 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 14:07:05 +0000
Subject: [PATCH 5/5] Add DriverDirectory support throughout configuration
chain
- Added DriverDirectory property to BaseConfigInfo (inherited by Configinfo and GlobalConfigInfo)
- Added DriverDirectory parameter to ProcessInfo constructor and as a JSON property
- Updated ConfigurationMapper to map DriverDirectory in MapToGlobalConfigInfo, MapToProcessInfo, and CopyBaseFields
- Updated InitializeFromEnvironment in GeneralUpdateBootstrap to read DriverDirectory from ProcessInfo
- This ensures DriverDirectory is properly propagated through the entire configuration pipeline
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Shared/Object/BaseConfigInfo.cs | 6 ++++++
.../Shared/Object/ConfigurationMapper.cs | 3 +++
.../GeneralUpdate.Common/Shared/Object/ProcessInfo.cs | 10 ++++++++++
src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs | 3 ++-
4 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/c#/GeneralUpdate.Common/Shared/Object/BaseConfigInfo.cs b/src/c#/GeneralUpdate.Common/Shared/Object/BaseConfigInfo.cs
index 02bff532..3bce46f2 100644
--- a/src/c#/GeneralUpdate.Common/Shared/Object/BaseConfigInfo.cs
+++ b/src/c#/GeneralUpdate.Common/Shared/Object/BaseConfigInfo.cs
@@ -92,5 +92,11 @@ public abstract class BaseConfigInfo
/// This script is executed after update to ensure proper file permissions.
///
public string Script { get; set; }
+
+ ///
+ /// The directory path containing driver files for driver update functionality.
+ /// Used when DriveEnabled is true to locate and install driver files during updates.
+ ///
+ public string DriverDirectory { get; set; }
}
}
diff --git a/src/c#/GeneralUpdate.Common/Shared/Object/ConfigurationMapper.cs b/src/c#/GeneralUpdate.Common/Shared/Object/ConfigurationMapper.cs
index 05b352d6..45e98d66 100644
--- a/src/c#/GeneralUpdate.Common/Shared/Object/ConfigurationMapper.cs
+++ b/src/c#/GeneralUpdate.Common/Shared/Object/ConfigurationMapper.cs
@@ -43,6 +43,7 @@ public static GlobalConfigInfo MapToGlobalConfigInfo(Configinfo source, GlobalCo
target.Scheme = source.Scheme;
target.Token = source.Token;
target.Script = source.Script;
+ target.DriverDirectory = source.DriverDirectory;
// Map GlobalConfigInfo-specific fields
target.UpdateUrl = source.UpdateUrl;
@@ -92,6 +93,7 @@ public static ProcessInfo MapToProcessInfo(
scheme: source.Scheme,
token: source.Token,
script: source.Script,
+ driverDirectory: source.DriverDirectory, // Driver directory for driver updates
blackFileFormats: blackFileFormats, // From BlackListManager
blackFiles: blackFiles, // From BlackListManager
skipDirectories: skipDirectories // From BlackListManager
@@ -127,6 +129,7 @@ public static void CopyBaseFields(TSource source, TTarget targ
target.Scheme = source.Scheme;
target.Token = source.Token;
target.Script = source.Script;
+ target.DriverDirectory = source.DriverDirectory;
}
}
}
diff --git a/src/c#/GeneralUpdate.Common/Shared/Object/ProcessInfo.cs b/src/c#/GeneralUpdate.Common/Shared/Object/ProcessInfo.cs
index 047beef8..8b8f6932 100644
--- a/src/c#/GeneralUpdate.Common/Shared/Object/ProcessInfo.cs
+++ b/src/c#/GeneralUpdate.Common/Shared/Object/ProcessInfo.cs
@@ -43,6 +43,7 @@ public ProcessInfo() { }
/// The URL scheme for update requests
/// The authentication token
/// The Linux permission script
+ /// The directory path containing driver files
/// List of file format extensions to skip
/// List of specific files to skip
/// List of directories to skip
@@ -64,6 +65,7 @@ public ProcessInfo(string appName
, string scheme
, string token
, string script
+ , string driverDirectory
, List blackFileFormats
, List blackFiles
, List skipDirectories)
@@ -98,6 +100,7 @@ public ProcessInfo(string appName
Scheme = scheme;
Token = token;
Script = script;
+ DriverDirectory = driverDirectory;
// Set blacklist parameters
BlackFileFormats = blackFileFormats;
@@ -229,5 +232,12 @@ public ProcessInfo(string appName
///
[JsonPropertyName("Script")]
public string Script { get; set; }
+
+ ///
+ /// The directory path containing driver files for driver update functionality.
+ /// Used when DriveEnabled is true to locate and install driver files.
+ ///
+ [JsonPropertyName("DriverDirectory")]
+ public string DriverDirectory { get; set; }
}
}
\ No newline at end of file
diff --git a/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs b/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs
index 7382da5c..36baf93c 100644
--- a/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs
+++ b/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs
@@ -221,7 +221,8 @@ private void InitializeFromEnvironment()
Token = processInfo.Token,
DriveEnabled = GetOption(UpdateOption.Drive) ?? false,
PatchEnabled = GetOption(UpdateOption.Patch) ?? true,
- Script = processInfo.Script
+ Script = processInfo.Script,
+ DriverDirectory = processInfo.DriverDirectory
};
}