Skip to content

Conversation

@YuliiaKovalova
Copy link
Member

@YuliiaKovalova YuliiaKovalova commented Oct 14, 2025

Context

Currently, in order to have Runtime="Net" executed out-of-proc, you must explicitly specify TaskFactory="TaskHostFactory" in the UsingTask element.

Changes Made

Added runtime mismatch validation when Runtime is explicitly specified to omit TaskFactory specification in UsingTask.

Regression

No

Risks

Low — validation logic only affects cases where Runtime is explicitly set.

Testing

Added a dedicated test.

Copilot AI review requested due to automatic review settings October 14, 2025 16:51
Copy link
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

Adds validation to ensure custom tasks execute out-of-process when a Runtime parameter (e.g., "Net") is explicitly specified but doesn't match the current process runtime. Previously, this required explicit TaskFactory="TaskHostFactory" in the UsingTask declaration.

Key Changes

  • Modified type loading logic to check if task host parameters match the current process
  • Introduced isTaskHostParamsMatchCurrentProc parameter to control metadata load context usage
  • Added end-to-end test validating out-of-process execution with explicit Runtime specification

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Shared/TypeLoader.cs Added isTaskHostParamsMatchCurrentProc parameter throughout type loading chain to enable runtime mismatch detection
src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs Initialized runtime mismatch detection by comparing task host parameters with current process
src/Build.UnitTests/TestAssets/ExampleNetTask/TestNetTaskWithImplicitParams/global.json Added SDK configuration for test asset to prevent SDK path resolution issues
src/Build.UnitTests/TestAssets/ExampleNetTask/TestNetTaskWithImplicitParams/TestNetTaskWithImplicitParams.csproj Created test project with Runtime="NET" to validate out-of-process execution
src/Build.UnitTests/NetTaskHost_E2E_Tests.cs Added test verifying task executes out-of-process when Runtime is specified without TaskHostFactory
src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj Added reference to new test asset's global.json file

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@YuliiaKovalova YuliiaKovalova changed the base branch from main to vs18.0 October 16, 2025 14:19
@YuliiaKovalova YuliiaKovalova enabled auto-merge (squash) October 21, 2025 08:41
@YuliiaKovalova YuliiaKovalova merged commit 995a3dc into vs18.0 Oct 21, 2025
10 checks passed
@YuliiaKovalova YuliiaKovalova deleted the dev/ykovalova/detect_runtime_missmatch branch October 21, 2025 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants