Skip to content

Commit 4090f47

Browse files
committed
Print warning if preview version (#4398)
1 parent fb46043 commit 4090f47

File tree

7 files changed

+59
-10
lines changed

7 files changed

+59
-10
lines changed

.vscode/launch.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5-
"name": ".NET Core Launch (console)",
5+
"name": "Run func cli (console)",
66
"type": "coreclr",
77
"request": "launch",
88
"preLaunchTask": "build",
9-
// If you have changed target frameworks, make sure to update the program path.
10-
"program": "${workspaceFolder}/out/bin/Azure.Functions.Cli/debug_net8.0/func.dll",
9+
"program": "${workspaceFolder}/out/bin/Azure.Functions.Cli/debug/func.dll",
1110
"env": {
1211
"CLI_DEBUG": "1"
1312
},
13+
// use `--script-root` to set func app directory e.g.
14+
// "args": "${input:funcArgs} --script-root ${workspaceFolder}/_testapp",
1415
"args": "${input:funcArgs}",
1516
"cwd": "${workspaceFolder}/src/Cli/func",
1617
"console": "internalConsole",

src/Cli/func/Actions/HelpAction.cs

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ private void DisplayGeneralHelp()
176176
.Where(c => c != Context.None)
177177
.Distinct()
178178
.OrderBy(c => c.ToLowerCaseString());
179+
Utilities.WarnIfPreviewVersion();
179180
Utilities.PrintVersion();
180181
ColoredConsole
181182
.WriteLine("Usage: func [context] [context] <action> [-/--options]")

src/Cli/func/Actions/HostActions/StartHostAction.cs

+2
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ public override async Task RunAsync()
409409
return;
410410
}
411411

412+
Utilities.WarnIfPreviewVersion();
413+
412414
if (isVerbose || EnvironmentHelper.GetEnvironmentVariableAsBool(Constants.DisplayLogo))
413415
{
414416
Utilities.PrintLogo();

src/Cli/func/Actions/LocalActions/InitAction.cs

+2
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ public override ICommandLineParserResult ParseArgs(string[] args)
154154

155155
public override async Task RunAsync()
156156
{
157+
Utilities.WarnIfPreviewVersion();
158+
157159
if (SourceControl != SourceControl.Git)
158160
{
159161
throw new Exception("Only Git is supported right now for vsc");

src/Cli/func/Azure.Functions.Cli.csproj

+8-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@
2020
</PropertyGroup>
2121

2222
<PropertyGroup>
23-
<BuildNumber Condition=" '$(BuildNumber)' == '' ">1</BuildNumber>
23+
<!-- Base version components -->
2424
<MajorMinorProductVersion>4.0</MajorMinorProductVersion>
25-
<Version>$(MajorMinorProductVersion).$(BuildNumber)</Version>
25+
<BuildNumber Condition=" '$(BuildNumber)' == '' ">1</BuildNumber>
26+
<CommitHash Condition="$(CommitHash) == ''">N/A</CommitHash>
27+
28+
<!-- Final version properties -->
29+
<Version>$(MajorMinorProductVersion).$(BuildNumber)-preview1</Version>
2630
<AssemblyVersion>$(MajorMinorProductVersion).$(BuildNumber)</AssemblyVersion>
2731
<FileVersion>$(MajorMinorProductVersion).$(BuildNumber)</FileVersion>
28-
<CommitHash Condition="$(CommitHash) == ''">N/A</CommitHash>
32+
33+
<InformationalVersion>$(Version) Commit hash: $(CommitHash) $(IntegrationBuildNumberInfo)</InformationalVersion>
2934
<IntegrationBuildNumberInfo Condition="$(IntegrationBuildNumber) != ''">Integration build number: $(IntegrationBuildNumber)</IntegrationBuildNumberInfo>
30-
<InformationalVersion>$(FileVersion) Commit hash: $(CommitHash) $(IntegrationBuildNumberInfo)</InformationalVersion>
3135
</PropertyGroup>
3236

3337
<ItemGroup>

src/Cli/func/Common/Constants.cs

+20-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Collections.ObjectModel;
55
using System.Reflection;
6+
using System.Text.RegularExpressions;
67
using Azure.Functions.Cli.Helpers;
78

89
namespace Azure.Functions.Cli.Common
@@ -96,10 +97,10 @@ internal static class Constants
9697
public const string Dotnet = "dotnet";
9798
public const string InProcDotNet8EnabledSetting = "FUNCTIONS_INPROC_NET8_ENABLED";
9899
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/
100101
public const string GitHubReleaseApiUrl = "https://api.github.com/repos/Azure/azure-functions-core-tools/releases/latest";
102+
public const string PreviewVersionSuffixLabel = "preview";
101103

102-
// Sample format https://n12abc3t-<port>.asse.devtunnels.ms/
103104
public static readonly Dictionary<WorkerRuntime, IEnumerable<string>> WorkerRuntimeImages = new Dictionary<WorkerRuntime, IEnumerable<string>>
104105
{
105106
{ 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
120121
"entityTrigger",
121122
];
122123

124+
private static readonly string _cliVersion = GetSemanticVersion();
125+
123126
#pragma warning disable SA1401 // Fields should be private
124127
public static string CliDetailedVersion = typeof(Constants).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? string.Empty;
125128
public static string CliUserAgent = $"functions-core-tools/{CliVersion}";
126129
#pragma warning restore SA1401 // Fields should be private
127130

128-
public static string CliVersion => typeof(Constants).GetTypeInfo().Assembly.GetName().Version.ToString(3);
131+
public static string CliVersion => _cliVersion;
129132

130133
public static ExtensionPackage ExtensionsMetadataGeneratorPackage => new ExtensionPackage { Name = "Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" };
131134

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+
132149
public static class Errors
133150
{
134151
public const string NoRunningInstances = "No running instances";

src/Cli/func/Common/Utilities.cs

+22
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,28 @@ internal static void PrintVersion()
5151
.WriteLine($"Function Runtime Version: {ScriptHost.Version}\n".DarkGray());
5252
}
5353

54+
internal static void WarnIfPreviewVersion()
55+
{
56+
if (!Constants.CliVersion.Contains(Constants.PreviewVersionSuffixLabel, StringComparison.OrdinalIgnoreCase))
57+
{
58+
return;
59+
}
60+
61+
ColoredConsole
62+
.WriteLine("You are running a preview version of Azure Functions Core Tools.".DarkYellow());
63+
64+
bool isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
65+
Architecture arch = RuntimeInformation.ProcessArchitecture;
66+
67+
if (isLinux && arch == Architecture.Arm64)
68+
{
69+
ColoredConsole
70+
.WriteLine("This version of the Azure Functions Core Tools currently doesn't support linux-arm64 with Python workers, with PowerShell workers, or with .NET applications using the in-process model.".DarkYellow());
71+
}
72+
73+
ColoredConsole.WriteLine();
74+
}
75+
5476
private static RichString AlternateLogoColor(string str, int firstColorCount = -1)
5577
{
5678
if (str.Length == 1)

0 commit comments

Comments
 (0)