Took the architecture from the build target instead of metadata.txt (#1070)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-10-16 08:13:18 +02:00
1 parent db2cbaa71e
commit 940d214429
11 files changed
+37 -155

No files matched your search

+2 -16
View File
@@ -251,7 +251,6 @@ public sealed partial class UpdateMetadataCommands
var rid = Environment.GetCurrentRid();
Console.WriteLine("==============================");
await this.UpdateArchitecture(rid);
await this.UpdateTauriVersion();
await this.UpdateVectorStoreVersion();
@@ -845,7 +844,7 @@ public sealed partial class UpdateMetadataCommands
private async Task<string> ReadPdfiumVersion()
{
const int PDFIUM_VERSION_INDEX = 10;
const int PDFIUM_VERSION_INDEX = 9;
var pathMetadata = Environment.GetMetadataPath();
var lines = await File.ReadAllLinesAsync(pathMetadata, Encoding.UTF8);
@@ -855,19 +854,6 @@ public sealed partial class UpdateMetadataCommands
return shortVersion;
}
private async Task UpdateArchitecture(RID rid)
{
const int ARCHITECTURE_INDEX = 9;
var pathMetadata = Environment.GetMetadataPath();
var lines = await File.ReadAllLinesAsync(pathMetadata, Encoding.UTF8);
Console.Write($"- Updating architecture to {rid.ToUserFriendlyName()} ...");
lines[ARCHITECTURE_INDEX] = rid.AsMicrosoftRid();
await WriteMetadataLinesAsync(pathMetadata, lines);
Console.WriteLine(" done.");
}
[Command("update-project-hash", Description = "Update the project commit hash")]
public async Task UpdateProjectCommitHash()
{
@@ -1016,7 +1002,7 @@ public sealed partial class UpdateMetadataCommands
private async Task UpdateVectorStoreVersion()
{
const int VECTOR_STORE_VERSION_INDEX = 11;
const int VECTOR_STORE_VERSION_INDEX = 10;
var pathMetadata = Environment.GetMetadataPath();
var lines = await File.ReadAllLinesAsync(pathMetadata, Encoding.UTF8);
@@ -128,9 +128,15 @@
<MetaMudBlazorVersion>$([System.String]::Copy( $(Metadata) ).Split( ';' )[ 6 ])</MetaMudBlazorVersion>
<MetaTauriVersion>$([System.String]::Copy( $(Metadata) ).Split( ';' )[ 7 ])</MetaTauriVersion>
<MetaAppCommitHash>$([System.String]::Copy( $(Metadata) ).Split( ';' )[ 8 ])</MetaAppCommitHash>
<MetaArchitecture>$([System.String]::Copy( $(Metadata) ).Split( ';' )[ 9 ])</MetaArchitecture>
<MetaPdfiumVersion>$([System.String]::Copy( $(Metadata) ).Split( ';' )[ 10 ])</MetaPdfiumVersion>
<MetaVectorStoreVersion>$([System.String]::Copy( $(Metadata) ).Split( ';' )[ 11 ])</MetaVectorStoreVersion>
<!--
The architecture is the one the app is built for. The build script and the pipeline pass it to
dotnet publish; in any other build, SelfContained makes the SDK pick the RID of this machine.
-->
<MetaArchitecture>$(RuntimeIdentifier)</MetaArchitecture>
<MetaPdfiumVersion>$([System.String]::Copy( $(Metadata) ).Split( ';' )[ 9 ])</MetaPdfiumVersion>
<MetaVectorStoreVersion>$([System.String]::Copy( $(Metadata) ).Split( ';' )[ 10 ])</MetaVectorStoreVersion>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
+1 -20
View File
@@ -1,10 +1,8 @@
using System.Diagnostics;
using System.Formats.Tar;
using System.IO.Compression;
using System.Reflection;
using System.Text.RegularExpressions;
using AIStudio.Tools.Metadata;
using AIStudio.Tools.Services;
using SharedTools;
@@ -15,12 +13,8 @@ public static partial class Pandoc
{
private static string TB(string fallbackEN) => PluginSystem.I18N.I.T(fallbackEN, typeof(Pandoc).Namespace, nameof(Pandoc));
private static readonly Assembly ASSEMBLY = Assembly.GetExecutingAssembly();
private static readonly MetaDataArchitectureAttribute META_DATA_ARCH = ASSEMBLY.GetCustomAttribute<MetaDataArchitectureAttribute>()!;
// Use runtime detection instead of metadata to ensure correct RID on dev machines:
// Pandoc is a program of its own, so it has to fit the machine, not the build of AI Studio:
private static readonly RID CPU_ARCHITECTURE = RIDExtensions.GetCurrentRID();
private static readonly RID METADATA_ARCHITECTURE = META_DATA_ARCH.Architecture.ToRID();
private const string DOWNLOAD_URL = "https://github.com/jgm/pandoc/releases/download";
private const string LATEST_URL = "https://github.com/jgm/pandoc/releases/latest";
@@ -66,19 +60,6 @@ public static partial class Pandoc
{
try
{
//
// Log a warning if the runtime-detected RID differs from the metadata RID.
// This can happen on dev machines where the metadata.txt contains stale values.
// We always use the runtime-detected RID for correct behavior.
//
if (!HAS_LOGGED_EXECUTABLE_ONCE && CPU_ARCHITECTURE != METADATA_ARCHITECTURE)
{
LOG.LogWarning(
"Runtime-detected RID '{RuntimeRID}' differs from metadata RID '{MetadataRID}'. Using runtime-detected RID. This is expected on dev machines where metadata.txt may be outdated.",
CPU_ARCHITECTURE.ToUserFriendlyName(),
METADATA_ARCHITECTURE.ToUserFriendlyName());
}
var preparedProcess = await PreparePandocProcess().AddArgument("--version").BuildAsync(rustService);
if (!HAS_LOGGED_EXECUTABLE_ONCE)
{
@@ -1,7 +1,5 @@
using System.Diagnostics;
using System.Reflection;
using AIStudio.Tools.Metadata;
using AIStudio.Tools.Rust;
using AIStudio.Tools.Services;
@@ -11,12 +9,8 @@ namespace AIStudio.Tools;
public sealed class PandocProcessBuilder
{
private static readonly Assembly ASSEMBLY = Assembly.GetExecutingAssembly();
private static readonly MetaDataArchitectureAttribute META_DATA_ARCH = ASSEMBLY.GetCustomAttribute<MetaDataArchitectureAttribute>()!;
// Use runtime detection instead of metadata to ensure correct RID on dev machines:
// Pandoc is a program of its own, so it has to fit the machine, not the build of AI Studio:
private static readonly RID CPU_ARCHITECTURE = RIDExtensions.GetCurrentRID();
private static readonly RID METADATA_ARCHITECTURE = META_DATA_ARCH.Architecture.ToRID();
private static readonly ILogger LOGGER = Program.LOGGER_FACTORY.CreateLogger(nameof(PandocProcessBuilder));
private const string FLATPAK_PANDOC_PLUGIN_BIN_DIRECTORY = "/app/plugins/pandoc/bin";
@@ -139,19 +133,6 @@ public sealed class PandocProcessBuilder
try
{
//
// Log a warning if the runtime-detected RID differs from the metadata RID.
// This can happen on dev machines where the metadata.txt contains stale values.
// We always use the runtime-detected RID for correct behavior.
//
if (shouldLog && CPU_ARCHITECTURE != METADATA_ARCHITECTURE)
{
LOGGER.LogWarning(
"Runtime-detected RID '{RuntimeRID}' differs from metadata RID '{MetadataRID}'. Using runtime-detected RID. This is expected on dev machines where metadata.txt may be outdated.",
CPU_ARCHITECTURE.ToUserFriendlyName(),
METADATA_ARCHITECTURE.ToUserFriendlyName());
}
//
// First, we try to find the pandoc executable in the data directory.
// Any local installation should be preferred over the system-wide installation.
+2 -2
View File
@@ -8,8 +8,8 @@ public static class RIDExtensions
/// Detects the current Runtime Identifier (RID) at runtime based on OS and architecture.
/// </summary>
/// <remarks>
/// This method should be preferred over reading the RID from metadata,
/// as the metadata may contain stale values in development environments.
/// This is the machine which runs the code. The architecture in the metadata of AI Studio
/// is the platform AI Studio was built for instead; both can differ under emulation.
/// </remarks>
/// <returns>The detected RID for the current platform.</returns>
public static RID GetCurrentRID()