|
1 | 1 | using System.Collections.Generic;
|
2 | 2 | using System.Collections.ObjectModel;
|
3 | 3 | using System.Reflection;
|
| 4 | +using System.Text.RegularExpressions; |
4 | 5 | using Azure.Functions.Cli.Helpers;
|
5 | 6 |
|
6 | 7 | namespace Azure.Functions.Cli.Common
|
@@ -94,17 +95,28 @@ internal static class Constants
|
94 | 95 | public const string Dotnet = "dotnet";
|
95 | 96 | public const string InProcDotNet8EnabledSetting = "FUNCTIONS_INPROC_NET8_ENABLED";
|
96 | 97 | public const string AzureDevSessionsRemoteHostName = "AzureDevSessionsRemoteHostName";
|
97 |
| - public const string AzureDevSessionsPortSuffixPlaceholder = "<port>"; |
| 98 | + public const string AzureDevSessionsPortSuffixPlaceholder = "<port>"; // forwardedHttpUrl sample format: https://n12abc3t-<port>.asse.devtunnels.ms/ |
98 | 99 | public const string GitHubReleaseApiUrl = "https://api.github.com/repos/Azure/azure-functions-core-tools/releases/latest";
|
| 100 | + public const string PreviewVersionSuffixLabel = "preview"; |
99 | 101 |
|
100 |
| - // Sample format https://n12abc3t-<port>.asse.devtunnels.ms/ |
101 |
| - |
| 102 | + private static readonly string _cliVersion = GetSemanticVersion(); |
| 103 | + public static string CliVersion => _cliVersion; |
| 104 | + public static string CliDetailedVersion = typeof(Constants).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? string.Empty; |
| 105 | + public static string CliUserAgent = $"functions-core-tools/{CliVersion}"; |
102 | 106 |
|
103 |
| - public static string CliVersion => typeof(Constants).GetTypeInfo().Assembly.GetName().Version.ToString(3); |
| 107 | + // Helper method to extract version from CliDetailedVersion |
| 108 | + private static string GetSemanticVersion() |
| 109 | + { |
| 110 | + var infoVersion = typeof(Constants).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion; |
104 | 111 |
|
105 |
| - public static string CliDetailedVersion = typeof(Constants).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? string.Empty; |
| 112 | + if (string.IsNullOrEmpty(infoVersion)) |
| 113 | + { |
| 114 | + return Assembly.GetExecutingAssembly().GetName().Version.ToString(3); |
| 115 | + } |
106 | 116 |
|
107 |
| - public static string CliUserAgent = $"functions-core-tools/{Constants.CliVersion}"; |
| 117 | + var match = Regex.Match(infoVersion, @"^(\S+)"); |
| 118 | + return match.Success ? match.Groups[1].Value : infoVersion; |
| 119 | + } |
108 | 120 |
|
109 | 121 | public static readonly Dictionary<WorkerRuntime, IEnumerable<string>> WorkerRuntimeImages = new Dictionary<WorkerRuntime, IEnumerable<string>>
|
110 | 122 | {
|
|
0 commit comments