Stop locking built assemblies in plugin and workflow-activity tasks (#40)#69
Open
zekelinAlex wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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/AssemblyLoadContextlogic.
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; |
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.
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