Skip to content

Stop locking built assemblies in plugin and workflow-activity tasks (#40)#69

Open
zekelinAlex wants to merge 1 commit into
TALXIS:masterfrom
zekelinAlex:users/alexander.zekelin/no-dll-lock-metadata-reader
Open

Stop locking built assemblies in plugin and workflow-activity tasks (#40)#69
zekelinAlex wants to merge 1 commit into
TALXIS:masterfrom
zekelinAlex:users/alexander.zekelin/no-dll-lock-metadata-reader

Conversation

@zekelinAlex

@zekelinAlex zekelinAlex commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

The tasks that generate *.dll.data.xml kept the built dll locked: to find types they loaded the assembly via reflection, and a loaded assembly stays pinned on the MSBuild node between builds, so the file couldn't be rebuilt. Types are now read straight from IL metadata instead.

This also fixed generation for workflow activities. It used to fail with "WorkflowActivities not found" because the host moved to .NET 10, where System.Activities.CodeActivity doesn't exist, so the assembly load found no types.
Close #40

@zekelinAlex zekelinAlex changed the title Stop locking built assemblies in plugin and workflow-activity tasks Stop locking built assemblies in plugin and workflow-activity tasks (#40) Jun 18, 2026
@TomProkop TomProkop requested a review from Copilot June 18, 2026 12:52

Copilot AI left a comment

Copy link
Copy Markdown

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 updates the Dataverse MSBuild tasks that generate *.dll.data.xml to avoid loading assemblies via reflection (which can lock output DLLs across builds) by scanning IL metadata instead. It also addresses workflow activity discovery failures on newer .NET hosts by removing runtime type-loading dependencies.

Changes:

  • Replaced reflection-based type discovery in plugin and workflow-activity tasks with an IL metadata scanner (MetadataTypeScanner).
  • Switched public key token retrieval to AssemblyName.GetAssemblyName(path) to avoid loading/locking assemblies.
  • Simplified probe directory handling and removed custom AssemblyResolve / AssemblyLoadContext logic.

Reviewed changes

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

File Description
src/Dataverse/Tasks/Tasks/EnsureWorkflowActivityAssemblyDataXml.cs Uses MetadataTypeScanner to find workflow activities without loading the DLL.
src/Dataverse/Tasks/Tasks/EnsurePluginAssemblyDataXml.cs Uses MetadataTypeScanner to find plugin types without loading the DLL.
src/Dataverse/Tasks/Services/MetadataTypeScanner.cs New IL-metadata-based scanner for public types, base-type checks, interface checks, and CRM registration attribute reads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +159 to +163
foreach (var named in value.NamedArguments)
{
if (named.Name == "Group" && named.Value is string groupArg)
group = groupArg;
}
Comment on lines +48 to +68
internal bool DerivesFromBaseType(MetadataReader reader, TypeDefinition typeDef, string baseSimpleName)
{
EntityHandle baseHandle = typeDef.BaseType;
int guard = 0;

while (!baseHandle.IsNil && guard++ < 200)
{
if (baseHandle.Kind == HandleKind.TypeDefinition)
{
var td = reader.GetTypeDefinition((TypeDefinitionHandle)baseHandle);
if (reader.GetString(td.Name) == baseSimpleName)
return true;

baseHandle = td.BaseType;
}
else if (baseHandle.Kind == HandleKind.TypeReference)
{
var tr = reader.GetTypeReference((TypeReferenceHandle)baseHandle);

if (reader.GetString(tr.Name) == baseSimpleName)
return true;
Comment on lines +156 to +157
if (!type.DerivesFromBaseType("CodeActivity"))
continue;
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.

EnsureWorkflowActivityAssemblyDataXml fails to discover scaffolded workflow activity assembly

2 participants