Skip to content

Print warning if preview version #4398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"name": "Run func cli (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/out/bin/Azure.Functions.Cli/debug_net8.0/func.dll",
"program": "${workspaceFolder}/out/bin/Azure.Functions.Cli/debug/func.dll",
"env": {
"CLI_DEBUG": "1"
},
// use `--script-root` to set func app directory e.g.
// "args": "${input:funcArgs} --script-root ${workspaceFolder}/_testapp",
"args": "${input:funcArgs}",
"cwd": "${workspaceFolder}/src/Cli/func",
"console": "internalConsole",
Expand Down
1 change: 1 addition & 0 deletions src/Cli/func/Actions/HelpAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ private void DisplayGeneralHelp()
.Where(c => c != Context.None)
.Distinct()
.OrderBy(c => c.ToLowerCaseString());
Utilities.WarnIfPreviewVersion();
Utilities.PrintVersion();
ColoredConsole
.WriteLine("Usage: func [context] [context] <action> [-/--options]")
Expand Down
4 changes: 3 additions & 1 deletion src/Cli/func/Actions/HostActions/StartHostAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,15 @@ public override async Task RunAsync()
{
await PreRunConditions();
var isVerbose = VerboseLogging.HasValue && VerboseLogging.Value;

// Return if running is delegated to another version of Core Tools
if (await TryHandleInProcDotNetLaunchAsync())
{
return;
}

Utilities.WarnIfPreviewVersion();

if (isVerbose || EnvironmentHelper.GetEnvironmentVariableAsBool(Constants.DisplayLogo))
{
Utilities.PrintLogo();
Expand Down
2 changes: 2 additions & 0 deletions src/Cli/func/Actions/LocalActions/InitAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ public override ICommandLineParserResult ParseArgs(string[] args)

public override async Task RunAsync()
{
Utilities.WarnIfPreviewVersion();

if (SourceControl != SourceControl.Git)
{
throw new Exception("Only Git is supported right now for vsc");
Expand Down
12 changes: 8 additions & 4 deletions src/Cli/func/Azure.Functions.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@
</PropertyGroup>

<PropertyGroup>
<BuildNumber Condition=" '$(BuildNumber)' == '' ">1</BuildNumber>
<!-- Base version components -->
<MajorMinorProductVersion>4.0</MajorMinorProductVersion>
<Version>$(MajorMinorProductVersion).$(BuildNumber)</Version>
<BuildNumber Condition=" '$(BuildNumber)' == '' ">1</BuildNumber>
<CommitHash Condition="$(CommitHash) == ''">N/A</CommitHash>

<!-- Final version properties -->
<Version>$(MajorMinorProductVersion).$(BuildNumber)-preview1</Version>
<AssemblyVersion>$(MajorMinorProductVersion).$(BuildNumber)</AssemblyVersion>
<FileVersion>$(MajorMinorProductVersion).$(BuildNumber)</FileVersion>
<CommitHash Condition="$(CommitHash) == ''">N/A</CommitHash>

<InformationalVersion>$(Version) Commit hash: $(CommitHash) $(IntegrationBuildNumberInfo)</InformationalVersion>
<IntegrationBuildNumberInfo Condition="$(IntegrationBuildNumber) != ''">Integration build number: $(IntegrationBuildNumber)</IntegrationBuildNumberInfo>
<InformationalVersion>$(FileVersion) Commit hash: $(CommitHash) $(IntegrationBuildNumberInfo)</InformationalVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
24 changes: 18 additions & 6 deletions src/Cli/func/Common/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using System.Text.RegularExpressions;
using Azure.Functions.Cli.Helpers;

namespace Azure.Functions.Cli.Common
Expand Down Expand Up @@ -94,17 +95,28 @@ internal static class Constants
public const string Dotnet = "dotnet";
public const string InProcDotNet8EnabledSetting = "FUNCTIONS_INPROC_NET8_ENABLED";
public const string AzureDevSessionsRemoteHostName = "AzureDevSessionsRemoteHostName";
public const string AzureDevSessionsPortSuffixPlaceholder = "<port>";
public const string AzureDevSessionsPortSuffixPlaceholder = "<port>"; // forwardedHttpUrl sample format: https://n12abc3t-<port>.asse.devtunnels.ms/
public const string GitHubReleaseApiUrl = "https://api.github.com/repos/Azure/azure-functions-core-tools/releases/latest";
public const string PreviewVersionSuffixLabel = "preview";

// Sample format https://n12abc3t-<port>.asse.devtunnels.ms/

private static readonly string _cliVersion = GetSemanticVersion();
public static string CliVersion => _cliVersion;
public static string CliDetailedVersion = typeof(Constants).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? string.Empty;
public static string CliUserAgent = $"functions-core-tools/{CliVersion}";

public static string CliVersion => typeof(Constants).GetTypeInfo().Assembly.GetName().Version.ToString(3);
// Helper method to extract version from CliDetailedVersion
private static string GetSemanticVersion()
{
var infoVersion = typeof(Constants).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;

public static string CliDetailedVersion = typeof(Constants).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? string.Empty;
if (string.IsNullOrEmpty(infoVersion))
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString(3);
}

public static string CliUserAgent = $"functions-core-tools/{Constants.CliVersion}";
var match = Regex.Match(infoVersion, @"^(\S+)");
return match.Success ? match.Groups[1].Value : infoVersion;
}

public static readonly Dictionary<WorkerRuntime, IEnumerable<string>> WorkerRuntimeImages = new Dictionary<WorkerRuntime, IEnumerable<string>>
{
Expand Down
22 changes: 22 additions & 0 deletions src/Cli/func/Common/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,28 @@ internal static void PrintVersion()
.WriteLine($"Function Runtime Version: {ScriptHost.Version}\n".DarkGray());
}

internal static void WarnIfPreviewVersion()
{
if (!Constants.CliVersion.Contains(Constants.PreviewVersionSuffixLabel, StringComparison.OrdinalIgnoreCase))
{
return;
}

ColoredConsole
.WriteLine("You are running a preview version of Azure Functions Core Tools.".DarkYellow());

bool isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
Architecture arch = RuntimeInformation.ProcessArchitecture;

if (isLinux && arch == Architecture.Arm64)
{
ColoredConsole
.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());
}

ColoredConsole.WriteLine();
}

private static RichString AlternateLogoColor(string str, int firstColorCount = -1)
{
if (str.Length == 1)
Expand Down