Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

Context

Migrates the Unzip task to use the TaskEnvironment API for thread-safe path resolution, following the pattern established in #12914. This enables the task to run safely in MSBuild's multithreaded execution model.

Changes Made

  • Add IMultiThreadableTask interface and [MSBuildMultiThreadableTask] attribute to Unzip class
  • Add TaskEnvironment property
  • Replace Path.GetFullPath() with TaskEnvironment.GetAbsolutePath() for:
    • Destination folder creation
    • Source file path resolution
    • Extracted file path resolution (with zip-slip protection preserved)
  • Update all unit tests to provide TaskEnvironmentHelper.CreateForTest() when instantiating the task

Testing

  • All 14 Unzip unit tests pass
  • Updated all test instantiations to provide TaskEnvironmentHelper.CreateForTest()

Notes

The zip-slip exploit protection check uses AbsolutePath.Value for string comparison to maintain the security validation while using thread-safe path resolution.

Original prompt

Migrate the Unzip task to use TaskEnvironment API based on the pattern used here: #12914

Make sure to preserve correctness, performance and that the tests pass


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@dotnet-policy-service
Copy link
Contributor

Hello @@copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo.

Copilot AI changed the title [WIP] Migrate Unzip task to use TaskEnvironment API Migrate Unzip task to use TaskEnvironment API Jan 26, 2026
Copilot AI requested a review from JanProvaznik January 26, 2026 10:05
Copy link
Member

@JanProvaznik JanProvaznik left a comment

Choose a reason for hiding this comment

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

@copilot one comment

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 migrates the Unzip task to use the TaskEnvironment API for thread-safe path resolution, enabling safe execution in MSBuild's multithreaded environment. This follows the established pattern from PR #12914 that migrated other file I/O tasks (Copy, Delete, MakeDir, RemoveDir, Touch).

Changes:

  • Added IMultiThreadableTask interface and [MSBuildMultiThreadableTask] attribute to enable multithreaded execution
  • Replaced process-global Path.GetFullPath() calls with thread-safe TaskEnvironment.GetAbsolutePath()
  • Updated all 17 test cases to provide TaskEnvironment instances via TaskEnvironmentHelper.CreateForTest()

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Tasks/Unzip.cs Added multithreadable task support and migrated three path resolution calls (destination folder, source file, extracted file path) to use TaskEnvironment API while preserving zip-slip security validation
src/Tasks.UnitTests/Unzip_Tests.cs Updated all 17 Unzip task instantiations to include TaskEnvironment property initialization

@JanProvaznik
Copy link
Member

blocked by #13120 for correctness

@JanProvaznik JanProvaznik marked this pull request as draft January 27, 2026 15:31
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