msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Save thread working directory for fallback in Expander and Modifiers

Open JanProvaznik opened this issue 1 month ago • 1 comments

Fixes #12851 #12800

Context

there are 2 places where it's impractical to pass TaskEnvironment but the code relies on CWD

  1. Expander
  2. Modifier on TaskItems -> FullPath

Changes Made

introduce AsyncLocal CWD variable tied to lifetime of a TaskEnvironment

Testing

updated existing tests to dispose the environment demo this fixes: AsyncLocalDemo.zip

Notes

this makes the Aspire starter project build

JanProvaznik avatar Dec 04 '25 13:12 JanProvaznik

@rainersigwald @AR-May this was in the prototype branch and seems very painful to avoid the thread static, so I just took it and made the lifecycle better. Should I try more to figure out the expander and metadata another way? I think it's quite bad UX to ban taskitem.GetMetadata("FullPath") in enlightened tasks :( that seems like something that customers would expect to work.

JanProvaznik avatar Dec 04 '25 17:12 JanProvaznik