Refactor RID handling to use the current RID only

This commit is contained in:
Thorsten Sommer 2025-05-02 18:12:49 +02:00
parent aac8b25ae2
commit cd4fafed1f
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
4 changed files with 123 additions and 90 deletions

View File

@ -17,5 +17,10 @@ public sealed class CheckRidsCommand
{ {
Console.WriteLine($"- {rid}"); Console.WriteLine($"- {rid}");
} }
Console.WriteLine();
Console.WriteLine("The RID for the current OS and CPU is:");
var currentRid = Environment.GetCurrentRid();
Console.WriteLine($"- {currentRid}");
} }
} }

View File

@ -105,9 +105,8 @@ public sealed partial class UpdateMetadataCommands
// Build the .NET project: // Build the .NET project:
// //
var pathApp = Environment.GetAIStudioDirectory(); var pathApp = Environment.GetAIStudioDirectory();
var rids = Environment.GetRidsForCurrentOS(); var rid = Environment.GetCurrentRid();
foreach (var rid in rids)
{
Console.WriteLine("=============================="); Console.WriteLine("==============================");
await this.UpdateArchitecture(rid); await this.UpdateArchitecture(rid);
@ -196,14 +195,9 @@ public sealed partial class UpdateMetadataCommands
Console.WriteLine($" - Error: {e.Message}"); Console.WriteLine($" - Error: {e.Message}");
} }
Console.WriteLine();
}
// //
// Build the Rust project / runtime: // Build the Rust project / runtime:
// //
Console.WriteLine("==============================");
Console.WriteLine("- Start building the Rust runtime ..."); Console.WriteLine("- Start building the Rust runtime ...");
var pathRuntime = Environment.GetRustRuntimeDirectory(); var pathRuntime = Environment.GetRustRuntimeDirectory();

View File

@ -17,7 +17,7 @@ public sealed class UpdateWebAssetsCommand
Console.WriteLine("========================="); Console.WriteLine("=========================");
Console.Write("- Updating web assets ..."); Console.Write("- Updating web assets ...");
var rid = Environment.GetRidsForCurrentOS().First(); var rid = Environment.GetCurrentRid();
var cwd = Environment.GetAIStudioDirectory(); var cwd = Environment.GetAIStudioDirectory();
var contentPath = Path.Join(cwd, "bin", "release", Environment.DOTNET_VERSION, rid.AsMicrosoftRid(), "publish", "wwwroot", "_content"); var contentPath = Path.Join(cwd, "bin", "release", Environment.DOTNET_VERSION, rid.AsMicrosoftRid(), "publish", "wwwroot", "_content");
var isMudBlazorDirectoryPresent = Directory.Exists(Path.Join(contentPath, "MudBlazor")); var isMudBlazorDirectoryPresent = Directory.Exists(Path.Join(contentPath, "MudBlazor"));

View File

@ -76,4 +76,38 @@ public static class Environment
Console.WriteLine($"Error: Unsupported OS '{RuntimeInformation.OSDescription}'"); Console.WriteLine($"Error: Unsupported OS '{RuntimeInformation.OSDescription}'");
return []; return [];
} }
public static RID GetCurrentRid()
{
var arch = RuntimeInformation.ProcessArchitecture;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
return arch switch
{
Architecture.X64 => RID.WIN_X64,
Architecture.Arm64 => RID.WIN_ARM64,
_ => RID.NONE,
};
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
return arch switch
{
Architecture.X64 => RID.OSX_X64,
Architecture.Arm64 => RID.OSX_ARM64,
_ => RID.NONE,
};
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
return arch switch
{
Architecture.X64 => RID.LINUX_X64,
Architecture.Arm64 => RID.LINUX_ARM64,
_ => RID.NONE,
};
Console.WriteLine($"Error: Unsupported OS '{RuntimeInformation.OSDescription}'");
return RID.NONE;
}
} }