Skip to content

Migrate Tlblmp and AxImp to Multithreaded Execution - #13708

Merged
AlesProkop merged 18 commits into
dotnet:mainfrom
AlesProkop:migrate-tlblmp-to-multithreaded
May 29, 2026
Merged

Migrate Tlblmp and AxImp to Multithreaded Execution#13708
AlesProkop merged 18 commits into
dotnet:mainfrom
AlesProkop:migrate-tlblmp-to-multithreaded

Conversation

@AlesProkop

@AlesProkop AlesProkop commented May 7, 2026

Copy link
Copy Markdown
Member

Fixes #13633
Fixes #13626

Context

TlbImp is an internal nested ToolTask used by ResolveComReference to wrap TlbImp.exe. This change marks the concrete TlbImp task as safe for MSBuild's multithreaded task model and audits the shared AxTlbBaseTask base class used by both TlbImp and AxImp.

Changes Made

  • Annotated TlbImp with [MSBuildMultiThreadableTask].

  • Annotated AxImp with [MSBuildMultiThreadableTask], since it is the other concrete task derived from AxTlbBaseTask.

  • Audited AxTlbBaseTask and routed file-system checks through TaskEnvironment.GetAbsolutePath() for:

    • ToolPath
    • SdkToolsPath
    • KeyFile
  • Kept tool command-line path arguments verbatim intentionally:

    • TypeLibName
    • OutputAssembly
    • ReferenceFiles
    • ActiveXControlName
    • RuntimeCallableWrapperAssembly
    • KeyFile when passed to TlbImp.exe / AxImp.exe

    These are resolved by the spawned tool relative to the task environment working directory provided by ToolTask, avoiding user-visible path inflation.

  • Did not migrate ResolveComReference itself in this PR. That task is broader and AppDomain/current-directory/cache-path sensitive, so it should be handled separately.

Notes

IMultiThreadableTask, TaskEnvironment, process launch via TaskEnvironment.GetProcessStartInfo(), and task environment variable handling are provided by the shared ToolTask base infrastructure.

Testing

  • Built src\Tasks\Microsoft.Build.Tasks.csproj successfully.
  • Ran focused GetAssemblyIdentity tests:
    • Microsoft.Build.Tasks.UnitTests.exe --filter-class Microsoft.Build.UnitTests.GetAssemblyIdentity_Tests --no-progress
    • Result: 9 passed, 0 failed

@AlesProkop AlesProkop changed the title migrate tlblmp [DRAFT, DNR] Migrate Tlblmp to Multithreaded Execution May 7, 2026
@AlesProkop
AlesProkop marked this pull request as ready for review May 7, 2026 12:24
Copilot AI review requested due to automatic review settings May 7, 2026 12:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 aims to make the COM interop wrapper ToolTasks (notably the nested ResolveComReference.TlbImp, via shared AxTlbBaseTask) safe under MSBuild’s multithreaded task execution model by removing reliance on global process state for path handling.

Changes:

  • Marked ResolveComReference.TlbImp as [MSBuildMultiThreadableTask] and updated its command-line generation to absolutize key path inputs via TaskEnvironment.GetAbsolutePath().
  • Updated AxTlbBaseTask to validate/tool-resolve using TaskEnvironment-based absolute paths (ToolPath/SdkToolsPath/KeyFile).
  • Updated unit tests to assert the new absolutized command-line arguments.

Reviewed changes

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

File Description
src/Tasks/TlbImp.cs Adds multithreadable annotation and absolutizes TypeLibName/OutputAssembly/ReferenceFiles in generated command line.
src/Tasks/AxTlbBaseTask.cs Absolutizes tool path resolution and strong-name key file handling/validation using TaskEnvironment.
src/Tasks.UnitTests/TlbImp_Tests.cs Updates expectations to match absolutized /reference, TypeLibName, and /out: arguments.
src/Tasks.UnitTests/AxTlbBaseTask_Tests.cs Updates /keyfile: expectation to match absolutized KeyFile argument.

Comment thread src/Tasks/AxTlbBaseTask.cs Outdated
Comment thread src/Tasks.UnitTests/TlbImp_Tests.cs
Comment thread src/Tasks/TlbImp.cs
Comment thread src/Tasks/AxTlbBaseTask.cs Outdated
@AlesProkop
AlesProkop requested a review from JanProvaznik May 12, 2026 07:23
Comment thread src/Tasks/TlbImp.cs Outdated
Comment thread src/Tasks/TlbReference.cs
@AlesProkop
AlesProkop requested a review from AR-May May 13, 2026 13:53
@AlesProkop

AlesProkop commented May 13, 2026

Copy link
Copy Markdown
Member Author

Reversed some changes. I am not sure about the scope of this ticket. @AR-May please, could you specify what exactly has to be migrated? (There are two classes depending on this one, and there is also ResolveComReference)

@AR-May

AR-May commented May 13, 2026

Copy link
Copy Markdown
Member

Reversed some changes. I am not sure about the scope of this ticket. @AR-May please, could you specify what exactly has to be migrated? (There are two classes depending on this one, and there is also ResolveComReference)

@AlesProkop I would suggest to enlighten both derived classes. There is no need to do it in separate pr, as those seems very similar and seems trivial for migration to me. We need to check how they are used in ResolveComReference, but I think so far as we have fallback defined everything should be correct. I suggest not to migrate ResolveComReference in this PR.

@AlesProkop AlesProkop changed the title Migrate Tlblmp to Multithreaded Execution Migrate Tlblmp and AxImp to Multithreaded Execution May 15, 2026

@JanProvaznik JanProvaznik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't see much value in this migration without migrating the whole ResolveComReference chain.

These tasks are never created by the TaskFactory system and routed, they're explicitly instantiated during ResolveComReference

Comment thread src/Tasks/StrongNameUtils.cs Outdated
Comment thread src/Tasks/AxTlbBaseTask.cs Outdated
@AR-May

AR-May commented May 19, 2026

Copy link
Copy Markdown
Member

I don't see much value in this migration without migrating the whole ResolveComReference chain.

These tasks are never created by the TaskFactory system and routed, they're explicitly instantiated during ResolveComReference

I rather thought that this pr would be the first step toward migrating ResolveComReference as next action.

This was referenced Aug 12, 2026
WarperSan pushed a commit to WarperSan/ThunderPipe that referenced this pull request Aug 12, 2026
Updated
[Microsoft.Build.Utilities.Core](https://github.com/dotnet/msbuild) from
18.8.2 to 18.9.6.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.Build.Utilities.Core's
releases](https://github.com/dotnet/msbuild/releases)._

## 18.9.6

## What's Changed
* [vs18.6] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/msbuild#13793
* [vs18.0] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/msbuild#13859
* [vs18.6] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/msbuild#13858
* [vs18.7] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/msbuild#13863
* CsWin32 follow-up: CLR metadata + TypeLib interop migration by
@​JeremyKuhne in dotnet/msbuild#13853
* Update vmr-sb-validation.yml for Azure Pipelines by @​meghnave in
dotnet/msbuild#13871
* Test: keep shell alive 15s in ToolTaskCanChangeCanonicalErrorFormat
(#​13734) by @​jankratochvilcz in
dotnet/msbuild#13878
* Add vs18.8 to merge-flow config by @​OvesN in
dotnet/msbuild#13877
* Stable branding for 18.8 release by @​OvesN in
dotnet/msbuild#13883
* Bump main to 18.9.0 after vs18.8 snap by @​OvesN in
dotnet/msbuild#13880
* Avoid checkout in insertion pipeline by @​rainersigwald in
dotnet/msbuild#13887
* Report actual launch path in MSB4216 for Runtime="NET" task host by
@​ViktorHofer in dotnet/msbuild#13889
* Migrate Tlblmp and AxImp to Multithreaded Execution by @​AlesProkop in
dotnet/msbuild#13708
* Replace ErrorUtilities assertion methods with Assumed API and BCL
throw helpers by @​DustinCampbell in
dotnet/msbuild#13790
* Fix CLR_E_SHIM_RUNTIMELOAD in RAR's IMetaDataDispenser activation by
@​JeremyKuhne in dotnet/msbuild#13899
* [main] Update dependencies from nuget/nuget.client by
@​dotnet-maestro[bot] in dotnet/msbuild#13905
* [main] Update dependencies from dotnet/arcade by @​dotnet-maestro[bot]
in dotnet/msbuild#13907
* [main] Update dependencies from dotnet/roslyn by @​dotnet-maestro[bot]
in dotnet/msbuild#13910
* [vs17.14] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/msbuild#13908
* [vs18.0] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/msbuild#13906
* Fix ToolTask output loss: increase EOF pipe timeout from 2s to 30s by
@​huulinhnguyen-dev in dotnet/msbuild#13767
* Improve symlink cycle condition by @​GangWang01 in
dotnet/msbuild#13901
* [vs18.6] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/msbuild#13904
* Add flaky-test detection and auto-fix agentic workflows by
@​ViktorHofer in dotnet/msbuild#13915
* Quote --ignore-exit-code values so the quarantine pipeline does not
shell-split on Unix by @​ViktorHofer in
dotnet/msbuild#13918
* Fix flaky-test detector PR-evidence loss and raise scan limits by
@​ViktorHofer in dotnet/msbuild#13919
* Tighten the pr review agent by @​JanKrivanek in
dotnet/msbuild#13921
* Add environment variables for governance detection by @​ViktorHofer in
dotnet/msbuild#13920
* Change IsPackable to true and add IsShipping flag by @​ViktorHofer in
dotnet/msbuild#13924
* [vs18.7] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/msbuild#13911
* Make flaky detector verify recurrence postdates the fix before
commenting by @​ViktorHofer in
dotnet/msbuild#13930
* Fix AbsolutePath.GetCanonicalForm process state leak on Windows by
@​OvesN in dotnet/msbuild#13788
* Fix flaky detector: unblock dnceng feed, fail fast, and defer
quarantine to a second run by @​ViktorHofer in
dotnet/msbuild#13936
* Update documentation for ImplicitUsings element by @​drewnoakes in
dotnet/msbuild#13900
* [vs18.6] Point OptProf bootstrapper at rel/stable instead of int.main
by @​AlesProkop in dotnet/msbuild#13923
* Add CS8618 suppressor for required MSBuild task properties by
@​AArnott in dotnet/msbuild#13926
* Tighten NodeLaunchData.EnvironmentOverrides nullability to
IDictionary<string, string?>? by @​OvesN with @​Copilot in
dotnet/msbuild#13815
* Fix ToolTask EOF wait to be STA-safe via CountdownEvent (MSB4018 in
AspNetCompiler) by @​YuliiaKovalova in
dotnet/msbuild#13917
* [automated] Merge branch 'vs18.6' => 'vs18.7' by @​github-actions[bot]
in dotnet/msbuild#13941
* Localized file check-in by OneLocBuild Task: Build definition ID 9434:
Build ID 14192258 by @​dotnet-bot in
dotnet/msbuild#13849
* Bumping to 10.0.8 runtime packages by @​OvesN in
dotnet/msbuild#13898
* Flaky-test workflow: reassure on empty PR list + drop local
reproduction (quarantine-first) by @​ViktorHofer in
dotnet/msbuild#13938
* [Flaky Test] Un-quarantine 5 consistently-green tests by
@​github-actions[bot] in dotnet/msbuild#13952
* Flaky-test detector: open PRs ready-for-review; drop
newly-filed-issues section from PR body by @​ViktorHofer in
dotnet/msbuild#13958
* [Flaky Test] Quarantine 4 flaky tests by @​github-actions[bot] in
dotnet/msbuild#13937
* Flaky-test: fix duplicate-issue bug by switching dedup key to a
visible code-block key by @​ViktorHofer in
dotnet/msbuild#13963
* CsWin32 follow-up: WindowsNative + VS Setup Configuration + remaining
hand-rolled interop by @​JeremyKuhne in
dotnet/msbuild#13872
* Add the reviewer release skill checking if the Learn article Change
waves is updated by @​GangWang01 in
dotnet/msbuild#13840
* [main] Source code updates from dotnet/dotnet by @​dotnet-maestro[bot]
in dotnet/msbuild#13977
 ... (truncated)

Commits viewable in [compare
view](dotnet/msbuild@v18.8.2...v18.9.6).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Microsoft.Build.Utilities.Core&package-manager=nuget&previous-version=18.8.2&new-version=18.9.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

Migrate TlbImp to multithreaded execution (MSBuild) Migrate AxImp to multithreaded execution (MSBuild)

5 participants