Skip to content

Commit

Permalink
[release/9.1] Update Dcp out of date error message (#7566)
Browse files Browse the repository at this point in the history
* 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

* Revert unnecessary change

---------

Co-authored-by: Eric Erhardt <[email protected]>
  • Loading branch information
github-actions[bot] and eerhardt authored Feb 12, 2025
1 parent 9d6a216 commit d058982
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 31 deletions.
33 changes: 32 additions & 1 deletion src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
));
}

Expand All @@ -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<AssemblyInformationalVersionAttribute>()?.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<AssemblyVersionAttribute>()?.Version, out var assemblyVersion))
{
return assemblyVersion.ToString(3);
}

return "<unknown>";
}

internal static void CheckDcpInfoAndLogErrors(ILogger logger, DcpOptions options, DcpInfo dcpInfo, bool throwIfUnhealthy = false)
{
var containerRuntime = options.ContainerRuntime;
Expand Down
4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ See https://aka.ms/dotnet/aspire/containers for more details on supported contai
<value>Application orchestrator dependency check returned an error: {0}</value>
</data>
<data name="DcpVersionCheckTooLowMessage" xml:space="preserve">
<value>Newer version of .NET Aspire workload is required to run the application. Run 'dotnet workload update' to get it.</value>
<value>Newer version of the Aspire.Hosting.AppHost package is required to run the application. Ensure you are referencing at least version '{0}'.</value>
</data>
<data name="LaunchSettingsFileDoesNotContainProfileExceptionMessage" xml:space="preserve">
<value>Launch settings file does not contain '{0}' profile.</value>
Expand All @@ -151,4 +151,4 @@ See https://aka.ms/dotnet/aspire/containers for more details on supported contai
<data name="ProjectFileNotFoundExceptionMessage" xml:space="preserve">
<value>Project file '{0}' was not found.</value>
</data>
</root>
</root>
4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Properties/xlf/Resources.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d058982

Please sign in to comment.