Migrate Tlblmp to Multithreaded Execution#13708
Open
AlesProkop wants to merge 1 commit intodotnet:mainfrom
Open
Migrate Tlblmp to Multithreaded Execution#13708AlesProkop wants to merge 1 commit intodotnet:mainfrom
AlesProkop wants to merge 1 commit intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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.TlbImpas[MSBuildMultiThreadableTask]and updated its command-line generation to absolutize key path inputs viaTaskEnvironment.GetAbsolutePath(). - Updated
AxTlbBaseTaskto validate/tool-resolve usingTaskEnvironment-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 on lines
+110
to
+112
| f => string.IsNullOrEmpty(f) | ||
| ? SdkToolsPathUtility.FileInfoExists(f) | ||
| : SdkToolsPathUtility.FileInfoExists(TaskEnvironment.GetAbsolutePath(f)), |
Comment on lines
41
to
49
| t.ReferenceFiles = new string[] { "File1.dll", "File2.dll" }; | ||
| CommandLine.ValidateHasParameter( | ||
| t, | ||
| "/reference:File1.dll", | ||
| "/reference:" + Path.GetFullPath("File1.dll"), | ||
| false /* no response file */); | ||
| CommandLine.ValidateHasParameter( | ||
| t, | ||
| "/reference:File2.dll", | ||
| "/reference:" + Path.GetFullPath("File2.dll"), | ||
| false /* no response file */); |
Comment on lines
239
to
244
| protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine) | ||
| { | ||
| // .ocx file being imported | ||
| commandLine.AppendFileNameIfNotNull(TypeLibName); | ||
| commandLine.AppendFileNameIfNotNull(AbsolutizeIfNotEmpty(TypeLibName)); | ||
|
|
||
| // options |
JanProvaznik
reviewed
May 7, 2026
| // throw an error. | ||
| // | ||
| // So use /publickey if that's all our KeyFile contains, but KeyFile otherwise. | ||
| string absoluteKeyFile = string.IsNullOrEmpty(KeyFile) ? KeyFile : TaskEnvironment.GetAbsolutePath(KeyFile).Value; |
Member
There was a problem hiding this comment.
does this really make sense?
I thought that for these tool tasks it's correct to give them the relative parameters, because their processes are spawned at the correct CWD (handled by ToolTask)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13633
Context
TlbImp is a nested ToolTask used by ResolveComReference to wrap TlbImp.exe. Its process invocation and path
resolution relied on global process state, blocking safe parallel execution under MSBuild's multithreaded task
model.
Changes Made
AxTlbBaseTask (covers AxImp too).
TaskEnvironment.GetAbsolutePath(), without leaking into [Output] properties.
TaskEnvironment.GetEnvironmentVariable().
Testing