From 0bc1640ef23352ad11e0da7a29f7ac01f8a691c3 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Tue, 11 Feb 2025 15:18:11 -0600 Subject: [PATCH 1/2] Update Dcp out of date error message Remove references to the workload and instead compute the current package version and tell the user to reference the version corresponding with Aspire.Hosting. Fix #7484 Related Work Items: #7 --- src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs | 33 ++++++++++++++++++- .../Properties/Resources.Designer.cs | 4 +-- src/Aspire.Hosting/Properties/Resources.resx | 4 +-- .../Properties/xlf/Resources.cs.xlf | 4 +-- .../Properties/xlf/Resources.de.xlf | 4 +-- .../Properties/xlf/Resources.es.xlf | 4 +-- .../Properties/xlf/Resources.fr.xlf | 4 +-- .../Properties/xlf/Resources.it.xlf | 4 +-- .../Properties/xlf/Resources.ja.xlf | 4 +-- .../Properties/xlf/Resources.ko.xlf | 4 +-- .../Properties/xlf/Resources.pl.xlf | 4 +-- .../Properties/xlf/Resources.pt-BR.xlf | 4 +-- .../Properties/xlf/Resources.ru.xlf | 4 +-- .../Properties/xlf/Resources.tr.xlf | 4 +-- .../Properties/xlf/Resources.zh-Hans.xlf | 4 +-- .../Properties/xlf/Resources.zh-Hant.xlf | 4 +-- 16 files changed, 62 insertions(+), 31 deletions(-) diff --git a/src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs b/src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs index 463e73b78c5..319a474608c 100644 --- a/src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs +++ b/src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Globalization; +using System.Reflection; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; @@ -161,7 +162,8 @@ private static void EnsureDcpVersion(DcpInfo dcpInfo) { throw new DistributedApplicationException(string.Format( CultureInfo.InvariantCulture, - Resources.DcpVersionCheckTooLowMessage + Resources.DcpVersionCheckTooLowMessage, + GetCurrentPackageVersion(typeof(DcpDependencyCheck).Assembly) )); } @@ -174,6 +176,35 @@ private static void EnsureDcpVersion(DcpInfo dcpInfo) } } + private static string GetCurrentPackageVersion(Assembly assembly) + { + // The package version is stamped into the assembly's AssemblyInformationalVersionAttribute at build time, followed by a '+' and + // the commit hash, e.g.: + // [assembly: AssemblyInformationalVersion("9.1.0-preview.1.25111.1+ad18db0213e9db8209bca0feb83fc801f34634f5)] + + var version = assembly.GetCustomAttribute()?.InformationalVersion; + + if (version is not null) + { + var plusIndex = version.IndexOf('+'); + + if (plusIndex > 0) + { + return version[..plusIndex]; + } + + return version; + } + + // Fallback to the first 3 parts of the assembly version + if (Version.TryParse(assembly.GetCustomAttribute()?.Version, out var assemblyVersion)) + { + return assemblyVersion.ToString(3); + } + + return ""; + } + internal static void CheckDcpInfoAndLogErrors(ILogger logger, DcpOptions options, DcpInfo dcpInfo, bool throwIfUnhealthy = false) { var containerRuntime = options.ContainerRuntime; diff --git a/src/Aspire.Hosting/Properties/Resources.Designer.cs b/src/Aspire.Hosting/Properties/Resources.Designer.cs index 306bc5a1039..1896a3f8a90 100644 --- a/src/Aspire.Hosting/Properties/Resources.Designer.cs +++ b/src/Aspire.Hosting/Properties/Resources.Designer.cs @@ -39,7 +39,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Aspire.Hosting.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Aspire.Hosting.Azure.Functions.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; @@ -125,7 +125,7 @@ internal static string DcpDependencyCheckFailedMessage { } /// - /// Looks up a localized string similar to Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it.. + /// Looks up a localized string similar to Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'.. /// internal static string DcpVersionCheckTooLowMessage { get { diff --git a/src/Aspire.Hosting/Properties/Resources.resx b/src/Aspire.Hosting/Properties/Resources.resx index 417b46e9f95..dded0025301 100644 --- a/src/Aspire.Hosting/Properties/Resources.resx +++ b/src/Aspire.Hosting/Properties/Resources.resx @@ -140,7 +140,7 @@ See https://aka.ms/dotnet/aspire/containers for more details on supported contai Application orchestrator dependency check returned an error: {0} - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. Launch settings file does not contain '{0}' profile. @@ -151,4 +151,4 @@ See https://aka.ms/dotnet/aspire/containers for more details on supported contai Project file '{0}' was not found. - \ No newline at end of file + diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.cs.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.cs.xlf index d29bff7d602..0572e764af7 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.cs.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.cs.xlf @@ -40,8 +40,8 @@ Další podrobnosti o podporovaných modulech runtime kontejnerů najdete na htt - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - Ke spuštění aplikace se vyžaduje novější verze úlohy .NET Aspire. Pokud ji chcete získat, spusťte příkaz dotnet workload update. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.de.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.de.xlf index a9f42548ac3..ce6bc93511f 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.de.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.de.xlf @@ -40,8 +40,8 @@ Weitere Informationen zu unterstützten Containerruntimes finden Sie unter „ht - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - Zum Ausführen der Anwendung ist eine neuere Version der Workload ".NET Aspire" erforderlich. Führen Sie "dotnet workload update" aus, um es abzurufen. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.es.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.es.xlf index e8ee4ed1e9e..8d1248fc295 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.es.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.es.xlf @@ -40,8 +40,8 @@ Consulte https://aka.ms/dotnet/aspire/containers para obtener más información - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - Se requiere una versión más reciente de la carga de trabajo de .NET Aspire para ejecutar la aplicación. Ejecute "dotnet workload update" para obtenerla. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.fr.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.fr.xlf index 4ef0d3df2d8..3b4229bc84c 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.fr.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.fr.xlf @@ -41,8 +41,8 @@ Pour plus d’informations sur les runtimes de conteneur pris en charge, consult - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - Une version plus récente de la charge de travail .NET Aspire est nécessaire pour exécuter l’application. Exécutez « dotnet workload update » pour l’obtenir. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.it.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.it.xlf index aea8c37adcf..fbdccd6b04d 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.it.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.it.xlf @@ -40,8 +40,8 @@ Vedere https://aka.ms/dotnet/aspire/containers per altri dettagli sui runtime de - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - Per eseguire l'applicazione, è necessaria una versione più recente del carico di lavoro di .NET Aspire. Per ottenerla, esegui "aggiornamento del carico di lavoro dotnet". + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.ja.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.ja.xlf index fd8d8efa26e..d14df0a889f 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.ja.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.ja.xlf @@ -40,8 +40,8 @@ See https://aka.ms/dotnet/aspire/containers for more details on supported contai - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - アプリケーションを実行するには、新しいバージョンの .NET Aspire ワークロードが必要です。'dotnet workload update' を実行して取得します。 + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.ko.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.ko.xlf index e0e98613558..0b0863c8139 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.ko.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.ko.xlf @@ -40,8 +40,8 @@ See https://aka.ms/dotnet/aspire/containers for more details on supported contai - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - 애플리케이션을 실행하려면 최신 버전의 .NET Aspire 워크로드가 필요합니다. 'dotnet 워크로드 업데이트'를 실행하여 가져옵니다. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.pl.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.pl.xlf index 01d03ea30b7..e1dd5c620a7 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.pl.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.pl.xlf @@ -40,8 +40,8 @@ Aby uzyskać więcej informacji o obsługiwanych środowiskach uruchomieniowych - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - Do uruchomienia aplikacji jest wymagana nowsza wersja obciążenia programu .NET — Aspire. Uruchom polecenie „dotnet workload update”, aby ją pobrać. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.pt-BR.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.pt-BR.xlf index 8d41ac52404..6ab3163a517 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.pt-BR.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.pt-BR.xlf @@ -40,8 +40,8 @@ Consulte https://aka.ms/dotnet/aspire/containers para obter mais detalhes sobre - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - A versão mais recente da carga de trabalho .NET Aspire é necessária para executar o aplicativo. Execute 'dotnet workload update' para obtê-la. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.ru.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.ru.xlf index f26fd09a858..f2997b77104 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.ru.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.ru.xlf @@ -40,8 +40,8 @@ See https://aka.ms/dotnet/aspire/containers for more details on supported contai - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - Для запуска приложения требуется более новая версия рабочей нагрузки .NET Aspire. Чтобы получить ее, используйте команду "dotnet workload update". + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.tr.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.tr.xlf index 9225935ae19..896974f6b27 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.tr.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.tr.xlf @@ -41,8 +41,8 @@ Desteklenen konteyner çalışma zamanları hakkında daha fazla ayrıntı için - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - Uygulamayı çalıştırmak için .NET Aspire iş yükünün daha yeni bir sürümü gereklidir. Almak için 'dotnet iş yükü güncelleştirmesini' çalıştırın. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.zh-Hans.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.zh-Hans.xlf index e9e6426508c..0e07cbe580f 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.zh-Hans.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.zh-Hans.xlf @@ -40,8 +40,8 @@ See https://aka.ms/dotnet/aspire/containers for more details on supported contai - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - 运行应用程序需要较新版本的 .NET Aspire 工作负载。运行“dotnet 工作负载更新”以获取它。 + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. diff --git a/src/Aspire.Hosting/Properties/xlf/Resources.zh-Hant.xlf b/src/Aspire.Hosting/Properties/xlf/Resources.zh-Hant.xlf index 75a2cc9d03d..e7d05e00357 100644 --- a/src/Aspire.Hosting/Properties/xlf/Resources.zh-Hant.xlf +++ b/src/Aspire.Hosting/Properties/xlf/Resources.zh-Hant.xlf @@ -40,8 +40,8 @@ See https://aka.ms/dotnet/aspire/containers for more details on supported contai - Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it. - 執行應用程式需要較新版本的 .NET Aspire 工作負載。執行 'dotnet workload update' 以取得它。 + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. + Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'. From 12c41a52f8cb68e97ff0d4ccab1e5bc8515d285a Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Tue, 11 Feb 2025 17:52:16 -0600 Subject: [PATCH 2/2] Revert unnecessary change --- src/Aspire.Hosting/Properties/Resources.Designer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Aspire.Hosting/Properties/Resources.Designer.cs b/src/Aspire.Hosting/Properties/Resources.Designer.cs index 1896a3f8a90..22c24cca041 100644 --- a/src/Aspire.Hosting/Properties/Resources.Designer.cs +++ b/src/Aspire.Hosting/Properties/Resources.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 @@ -39,7 +39,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Aspire.Hosting.Azure.Functions.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Aspire.Hosting.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan;