Skip to content

Fix targetFramework detection incorrectly matching folder names containing "net" in deploy path#5021

Open
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-azure-functions-config-parsing
Open

Fix targetFramework detection incorrectly matching folder names containing "net" in deploy path#5021
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-azure-functions-config-parsing

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

The original TFM detection matched net anywhere in the deploy subpath string, causing false positives when project folder names contained net followed by digits/dots (e.g. Planet.net8.0, my_net8.0). This triggered a spurious mismatch warning and caused "Update VS Code config" to corrupt the folder name portion of azureFunctions.deploySubpath instead of updating the actual TFM segment. A lookbehind/lookahead approach still left two gaps: characters like _ or - before net satisfied the lookbehind, and .match() returning the first occurrence meant a project folder named like a TFM (e.g. net8.0/bin/Release/net6.0/publish) would be corrupted before the real TFM segment was reached.

Changes

  • src/vsCodeConfig/verifyTargetFramework.ts: Replaced the generic targetFrameworkRegExp with a buildOutputPattern anchored to the known .NET build output path structure bin/(Debug|Release)/<TFM>:
// Before
const targetFrameworkRegExp: RegExp = /net(standard|coreapp)?[0-9.]+/i;

// After — anchors TFM detection to the known build output path segment
const buildOutputPattern: RegExp = /\bbin([/\\])(Debug|Release)\1(net(?:standard|coreapp)?[0-9.]+)/i;

The TFM is extracted from capture group 3 (always within bin/Debug/<TFM> or bin/Release/<TFM>), and the replacement function reconstructs only that segment while preserving the path separator and build type. For a path like net8.0/bin/Release/net6.0/publish, the pattern correctly identifies net6.0 as the TFM regardless of what precedes bin/.

Copilot AI self-assigned this May 13, 2026
Copilot AI review requested due to automatic review settings May 13, 2026 18:19
Copilot AI review requested due to automatic review settings May 13, 2026 18:19
…atching TFMs within folder names

Agent-Logs-Url: https://github.com/microsoft/vscode-azurefunctions/sessions/19007dbe-3fe6-4e77-8e34-ed5bf16fbc3d

Co-authored-by: nturinski <5290572+nturinski@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 13, 2026 18:26
Copilot AI changed the title [WIP] Fix Azure Functions extension config parsing issue Fix targetFramework regex incorrectly matching folder names containing "net" in deploy path May 13, 2026
Copilot AI requested a review from nturinski May 13, 2026 18:27
@nturinski nturinski marked this pull request as ready for review May 18, 2026 22:48
@nturinski nturinski requested a review from a team as a code owner May 18, 2026 22:48
Copilot AI review requested due to automatic review settings May 18, 2026 22:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens .NET target framework detection in VS Code config verification to reduce false positives when deploy paths include folder names containing net.

Changes:

  • Updates the target framework regex to avoid matching net... after letters, digits, or dots.
  • Adds an inline comment explaining the folder-name false-positive case.

// https://docs.microsoft.com/dotnet/standard/frameworks
const targetFrameworkRegExp: RegExp = /net(standard|coreapp)?[0-9.]+/i;
// Use negative lookbehind to avoid matching "net" when it's part of a folder name (e.g. "Planet.net8.0")
const targetFrameworkRegExp: RegExp = /(?<![a-zA-Z0-9.])net(standard|coreapp)?[0-9.]+(?![a-zA-Z0-9])/i;
// https://docs.microsoft.com/dotnet/standard/frameworks
const targetFrameworkRegExp: RegExp = /net(standard|coreapp)?[0-9.]+/i;
// Use negative lookbehind to avoid matching "net" when it's part of a folder name (e.g. "Planet.net8.0")
const targetFrameworkRegExp: RegExp = /(?<![a-zA-Z0-9.])net(standard|coreapp)?[0-9.]+(?![a-zA-Z0-9])/i;
@nturinski
Copy link
Copy Markdown
Member

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits May 19, 2026 18:03
…fix false positives and first-match issues

Agent-Logs-Url: https://github.com/microsoft/vscode-azurefunctions/sessions/645f301f-6011-4722-be45-447828623a34

Co-authored-by: nturinski <5290572+nturinski@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 19, 2026

@copilot apply changes based on the comments in this thread

Applied in d105304. Replaced the lookbehind/lookahead approach with a pattern anchored to the known .NET build output path structure: /\bbin([/\\])(Debug|Release)\1(net(?:standard|coreapp)?[0-9.]+)/i.

This fixes both issues raised in the review:

  1. Prefix characters like _/-: No longer a concern — the pattern only matches net... when it appears after bin/(Debug|Release)/, so my_net8.0/bin/Release/net6.0/publish correctly identifies net6.0 as the TFM.
  2. First-match problem: Also fixed — the regex targets the TFM within the specific bin/Debug or bin/Release segment, so net8.0/bin/Release/net6.0/publish finds net6.0, not the project folder.

The replacement function reconstructs the matched segment (bin${sep}${buildType}${sep}${newTFM}) so only the TFM portion changes while the rest of the path is untouched.

Copilot AI changed the title Fix targetFramework regex incorrectly matching folder names containing "net" in deploy path Fix targetFramework detection incorrectly matching folder names containing "net" in deploy path May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Azure Functions extension incorrectly parses project path as targetFramework when updating VS Code config

3 participants