From 99ac0fbf1511be6cb92562d4f40d26593a2e360b Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim <109541540+v-imohammad@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:55:36 -0700 Subject: [PATCH] Hotfix 4.0.5907 Tag and adding (#3773) (#3797) commit to branch (#3808) * Setting executable permissions for `in-proc8/func` executable in install code path. (#3797) * Fix Issue 3594: Look for csproj and fsproj non-recursively (#3773) * add searchOption parameter to GetFiles to allow for non-recursive searching use non-recursive searching when looking for .csproj and .fsproj files during validation. --------- Co-authored-by: Shyju Krishnankutty Co-authored-by: Ryan Adams --- src/Azure.Functions.Cli/Common/FileSystemHelpers.cs | 9 +++++++-- src/Azure.Functions.Cli/Helpers/DotnetHelpers.cs | 5 +++-- src/Azure.Functions.Cli/npm/lib/install.js | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Azure.Functions.Cli/Common/FileSystemHelpers.cs b/src/Azure.Functions.Cli/Common/FileSystemHelpers.cs index c11509c1a..0c7f56e01 100644 --- a/src/Azure.Functions.Cli/Common/FileSystemHelpers.cs +++ b/src/Azure.Functions.Cli/Common/FileSystemHelpers.cs @@ -158,7 +158,7 @@ bool preCondition(string file) } } - internal static IEnumerable GetFiles(string directoryPath, IEnumerable excludedDirectories = null, IEnumerable excludedFiles = null, string searchPattern = "*") + internal static IEnumerable GetFiles(string directoryPath, IEnumerable excludedDirectories = null, IEnumerable excludedFiles = null, string searchPattern = "*", SearchOption searchOption = SearchOption.AllDirectories) { foreach (var file in Instance.Directory.GetFiles(directoryPath, searchPattern, SearchOption.TopDirectoryOnly)) { @@ -170,13 +170,18 @@ internal static IEnumerable GetFiles(string directoryPath, IEnumerable d.Equals(directoryName, StringComparison.OrdinalIgnoreCase))) { - foreach (var file in GetFiles(directory, excludedDirectories, excludedFiles, searchPattern)) + foreach (var file in GetFiles(directory, excludedDirectories, excludedFiles, searchPattern, searchOption)) { yield return file; } diff --git a/src/Azure.Functions.Cli/Helpers/DotnetHelpers.cs b/src/Azure.Functions.Cli/Helpers/DotnetHelpers.cs index 9983011b9..ee637b674 100644 --- a/src/Azure.Functions.Cli/Helpers/DotnetHelpers.cs +++ b/src/Azure.Functions.Cli/Helpers/DotnetHelpers.cs @@ -155,8 +155,9 @@ internal static IEnumerable GetTemplates(WorkerRuntime workerRuntime) public static bool CanDotnetBuild() { EnsureDotnet(); - var csProjFiles = FileSystemHelpers.GetFiles(Environment.CurrentDirectory, searchPattern: "*.csproj").ToList(); - var fsProjFiles = FileSystemHelpers.GetFiles(Environment.CurrentDirectory, searchPattern: "*.fsproj").ToList(); + // dotnet build will only search for .csproj files within the current directory (when no .csproj file is passed), so we limit our search to that directory only + var csProjFiles = FileSystemHelpers.GetFiles(Environment.CurrentDirectory, searchPattern: "*.csproj", searchOption: SearchOption.TopDirectoryOnly).ToList(); + var fsProjFiles = FileSystemHelpers.GetFiles(Environment.CurrentDirectory, searchPattern: "*.fsproj", searchOption: SearchOption.TopDirectoryOnly).ToList(); // If the project name is extensions only then is extensions.csproj a valid csproj file if (!Path.GetFileName(Environment.CurrentDirectory).Equals("extensions")) { diff --git a/src/Azure.Functions.Cli/npm/lib/install.js b/src/Azure.Functions.Cli/npm/lib/install.js index e523d0a41..a99f3ecbf 100644 --- a/src/Azure.Functions.Cli/npm/lib/install.js +++ b/src/Azure.Functions.Cli/npm/lib/install.js @@ -98,6 +98,7 @@ https.get(options, response => { if (os.platform() === 'linux' || os.platform() === 'darwin') { fs.chmodSync(`${installPath}/func`, 0o755); fs.chmodSync(`${installPath}/gozip`, 0o755); + fs.chmodSync(`${installPath}/in-proc8/func`, 0o755); } }); });