3
3
4
4
using System . Collections . ObjectModel ;
5
5
using System . Reflection ;
6
+ using System . Text . RegularExpressions ;
6
7
using Azure . Functions . Cli . Helpers ;
7
8
8
9
namespace Azure . Functions . Cli . Common
@@ -96,10 +97,10 @@ internal static class Constants
96
97
public const string Dotnet = "dotnet" ;
97
98
public const string InProcDotNet8EnabledSetting = "FUNCTIONS_INPROC_NET8_ENABLED" ;
98
99
public const string AzureDevSessionsRemoteHostName = "AzureDevSessionsRemoteHostName" ;
99
- public const string AzureDevSessionsPortSuffixPlaceholder = "<port>" ;
100
+ public const string AzureDevSessionsPortSuffixPlaceholder = "<port>" ; // forwardedHttpUrl sample format: https://n12abc3t-<port>.asse.devtunnels.ms/
100
101
public const string GitHubReleaseApiUrl = "https://api.github.com/repos/Azure/azure-functions-core-tools/releases/latest" ;
102
+ public const string PreviewVersionSuffixLabel = "preview" ;
101
103
102
- // Sample format https://n12abc3t-<port>.asse.devtunnels.ms/
103
104
public static readonly Dictionary < WorkerRuntime , IEnumerable < string > > WorkerRuntimeImages = new Dictionary < WorkerRuntime , IEnumerable < string > >
104
105
{
105
106
{ WorkerRuntime . Dotnet , new [ ] { "mcr.microsoft.com/azure-functions/dotnet" , "microsoft/azure-functions-dotnet-core2.0" , "mcr.microsoft.com/azure-functions/base" , "microsoft/azure-functions-base" } } ,
@@ -120,15 +121,31 @@ internal static class Constants
120
121
"entityTrigger" ,
121
122
] ;
122
123
124
+ private static readonly string _cliVersion = GetSemanticVersion ( ) ;
125
+
123
126
#pragma warning disable SA1401 // Fields should be private
124
127
public static string CliDetailedVersion = typeof ( Constants ) . Assembly . GetCustomAttribute < AssemblyInformationalVersionAttribute > ( ) ? . InformationalVersion ?? string . Empty ;
125
128
public static string CliUserAgent = $ "functions-core-tools/{ CliVersion } ";
126
129
#pragma warning restore SA1401 // Fields should be private
127
130
128
- public static string CliVersion => typeof ( Constants ) . GetTypeInfo ( ) . Assembly . GetName ( ) . Version . ToString ( 3 ) ;
131
+ public static string CliVersion => _cliVersion ;
129
132
130
133
public static ExtensionPackage ExtensionsMetadataGeneratorPackage => new ExtensionPackage { Name = "Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" } ;
131
134
135
+ // Helper method to extract version from CliDetailedVersion
136
+ private static string GetSemanticVersion ( )
137
+ {
138
+ var infoVersion = typeof ( Constants ) . Assembly . GetCustomAttribute < AssemblyInformationalVersionAttribute > ( ) ? . InformationalVersion ;
139
+
140
+ if ( string . IsNullOrEmpty ( infoVersion ) )
141
+ {
142
+ return Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version . ToString ( 3 ) ;
143
+ }
144
+
145
+ var match = Regex . Match ( infoVersion , @"^(\S+)" ) ;
146
+ return match . Success ? match . Groups [ 1 ] . Value : infoVersion ;
147
+ }
148
+
132
149
public static class Errors
133
150
{
134
151
public const string NoRunningInstances = "No running instances" ;
0 commit comments