Skip to content

Conversation

@JanProvaznik
Copy link
Member

Fixes #12680

Context

When code file for RoslynCodeTaskFactory/CodeTaskFactory is specified, it is fetched relative to cwd which in multiprocess is equal to project directory but in multithreaded this is no longer the case.

Changes Made

Get Project path from buildengine in taskfactory initialization

change only in mt mode to align mt behavior with multiproc

Testing

integration and unit test

Notes

Copilot AI review requested due to automatic review settings October 21, 2025 11:27
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

This PR fixes a bug where inline task code files with relative paths fail to resolve correctly in multithreaded builds. In multiprocess builds, relative paths work because the current working directory matches the project directory, but in multithreaded mode this is no longer true.

Key Changes:

  • Added path resolution logic that resolves relative code file paths against the project directory instead of CWD in multithreaded mode
  • Modified both RoslynCodeTaskFactory and CodeTaskFactory to use the new resolution logic
  • Added comprehensive integration and unit tests to verify the fix

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/UnitTests.Shared/MockEngine.cs Changed ProjectFileOfTaskNode from read-only to settable property to support test scenarios
src/Tasks/RoslynCodeTaskFactory/RoslynCodeTaskFactory.cs Added project-relative path resolution for code source files in multithreaded builds
src/Tasks/CodeTaskFactory.cs Added project-relative path resolution for code source files in multithreaded builds
src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs Added integration test with multi-project solution and unit test for path resolution logic
src/Shared/TaskFactoryUtilities.cs Added ResolveTaskSourceCodePath utility method to handle path resolution logic

…tform paths

- Guard against empty ProjectFileOfTaskNode by checking before Path.GetDirectoryName
- Use Path.Combine for cross-platform path separators in test
- Fixes ArgumentException on empty path and FileNotFoundException on Linux
@JanProvaznik
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JanProvaznik
Copy link
Member Author

validated it resolves the problem for MSBuild-building-MSBuild with -mt on the commit from the original issue.

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.

Multithreaded inline task factories should work with relative paths to code files

1 participant