-
Notifications
You must be signed in to change notification settings - Fork 1.4k
load inline task code file relatively to project instead of CWD #12687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…an cwd in mt mode, add test
There was a problem hiding this 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
RoslynCodeTaskFactoryandCodeTaskFactoryto 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
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
validated it resolves the problem for MSBuild-building-MSBuild with -mt on the commit from the original issue. |
Fixes #12680
Context
When code file for
RoslynCodeTaskFactory/CodeTaskFactoryis 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