Skip to content

Conversation

@rishabhmalikMS
Copy link

@rishabhmalikMS rishabhmalikMS commented Dec 22, 2025

Description

Fixes Microsoft.IO.Redist v6.0.0.1 vs v6.1.0.0 assembly binding conflicts affecting VSBuild task in Visual Studio 2022 v17.14+. The existing feature flag MSBUILDHELPERS_ENABLE_GETMSBUILDPATHV2 was not functional due to telemetry logic calling V1 first, causing the assembly conflict before V2 could bypass it.

Problem:

  • Get-MSBuildPath (V1) uses Assembly.LoadFrom() which loads Microsoft.IO.Redist v6.0.0.1
  • VS 2022 v17.14+ includes Microsoft.IO.Redist v6.1.0.0, causing binding failures
  • Existing V2 function bypasses reflection but was never called due to telemetry blocking execution
  • Customer builds failing with cryptic "Could not load file or assembly" errors

Changes:

  • Refactored into 3 helper functions for clean separation of concerns:
    • Invoke-MSBuildPathLookup: V2→V1 fallback with exception handling
    • Emit-MSBuildPathTelemetry: Telemetry emission accepting cached paths
    • Select-MSBuildPath: Orchestrator passing feature flags through version iteration
  • V2 function now executes FIRST when feature flag enabled (was blocked by telemetry)
  • Added graceful exception handling around both V1 and V2 calls
  • Eliminated duplicate function calls: V1/V2 invoked once, results cached and reused
  • Enhanced telemetry to capture ALL scenarios including failures:
    • true/false (both succeed, paths match/don't match)
    • "V1Failed_V2Success" (V2 works, V1 has assembly conflict)
    • "V1Success_V2Failed" (V1 works, V2 fails)
    • "BothFailed" (neither function returns path)
  • Telemetry now emits even when lookup fails (removed resolvedPath guard)
  • Changed Write-Error to throw for immediate task failure (respects ErrorActionPreference)

Work item: AB#2338296

Summarize the changes made in this PR clearly and concisely. Highlight the purpose and impact of the changes.


Package Name

Name of the updated or newly created shared npm package.


Risk Assessment (Low / Medium / High)

Low

  • Changes are not adding any new functional capability. Changes only cover error handling missing in previous implementation.
  • Fixed proper sequence of get ms build path v1 and v2 functions as per existing feature flags.

Unit Tests Added or Updated

  • Unit tests added or updated
  • Manual tests performed

Additional Testing Performed

Test pipeline link with changes: https://dev.azure.com/rishabhmalikOrg/Test%20Project/Test%20Project%20Team/_build/results?buildId=2159&view=logs&j=12f1170f-54f2-53f3-20dd-22fc7dff55f9&t=2cccd56d-f2bb-5d36-e6bc-0f6d6ac6ba90&l=119


Documentation Changes Required (Yes / No)

Indicate whether related documentation needs to be updated. Provide links to the updated documentation if applicable.


Dependencies

List any dependencies introduced or updated in this PR.


Checklist


Fixes Microsoft.IO.Redist assembly binding conflicts in VS 2022 v17.14+ by enabling
feature flag MSBUILDHELPERS_ENABLE_GETMSBUILDPATHV2 to actually use Get-MSBuildPathV2.

Changes:
- Refactored into 3 helper functions for clean separation of concerns:
  * Invoke-MSBuildPathLookup: V2→V1 fallback with exception handling
  * Emit-MSBuildPathTelemetry: Telemetry emission accepting cached paths
  * Select-MSBuildPath: Orchestrator passing feature flags through version iteration
- V2 function now executes FIRST when feature flag enabled (was blocked by telemetry)
- Added graceful exception handling around both V1 and V2 calls
- Eliminated duplicate function calls: V1/V2 invoked once, results cached and reused
- Enhanced telemetry to capture ALL scenarios including failures:
  * true/false (both succeed, paths match/don't match)
  * "V1Failed_V2Success" (V2 works, V1 has assembly conflict)
  * "V1Success_V2Failed" (V1 works, V2 fails)
  * "BothFailed" (neither function returns path)
- Telemetry now emits even when lookup fails (removed resolvedPath guard)
- Changed Write-Error to throw for immediate task failure (respects ErrorActionPreference)
@rishabhmalikMS
Copy link
Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rishabhmalikMS
Copy link
Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rishabhmalikMS
Copy link
Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rishabhmalikMS rishabhmalikMS marked this pull request as draft December 22, 2025 08:22
@rishabhmalikMS
Copy link
Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

2 participants