Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/Tasks/GetAssembliesMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ namespace Microsoft.Build.Tasks
/// Resolves metadata for the specified set of assemblies.
/// </summary>
[SupportedOSPlatform("windows")]
public class GetAssembliesMetadata : TaskExtension
[MSBuildMultiThreadableTask]
public class GetAssembliesMetadata : TaskExtension, IMultiThreadableTask
{
/// <inheritdoc />
public TaskEnvironment TaskEnvironment { get; set; } = TaskEnvironment.Fallback;

/// <summary>
/// Assembly paths.
/// </summary>
Expand All @@ -38,15 +42,27 @@ public override bool Execute()
var assembliesMetadata = new List<ITaskItem>();
foreach (string assemblyPath in AssemblyPaths)
{
// Preserve original behavior: silently skip null/empty entries instead of throwing
// ArgumentException from GetAbsolutePath (Sin 6).
if (string.IsNullOrEmpty(assemblyPath))
{
continue;
}

AbsolutePath absoluteAssemblyPath = TaskEnvironment.GetAbsolutePath(assemblyPath);

// During DTB the referenced project may not has been built yet, so we need to check if the assembly already exists.
if (FileSystems.Default.FileExists(assemblyPath))
if (FileSystems.Default.FileExists(absoluteAssemblyPath))
{
using (AssemblyInformation assemblyInformation = new(assemblyPath))
using (AssemblyInformation assemblyInformation = new(absoluteAssemblyPath))
{
AssemblyAttributes attributes = assemblyInformation.GetAssemblyMetadata();

if (attributes != null)
{
// Preserve original [Output] behavior (Sin 1): emit the user-supplied path,
// not the absolutized form, as the resulting item's ItemSpec.
attributes.AssemblyFullPath = absoluteAssemblyPath.OriginalValue;
assembliesMetadata.Add(CreateItemWithMetadata(attributes));
}
}
Expand Down
Loading