mercredi 18 mai 2016

Inline MS Build Task in separate AppDomain

End Goal:

I would like to have a custom build task that takes my compiled assembly, and extracts all instances of a particular attribute for automated documentation and uninstallation. (In this case the GUID attribute for a set of COM-visible types).

Problem:

After reading some examples, the prospect of using an Inline Build Task was rather tempting. However, my task needs to reflect across the built assemblies and extract certain meta-data from it (specifically attributes).

The catch is reflecting over the assembly will lock the output file until the AppDomain is unloaded, which in this case appears to be only when Visual Studio is closed. The result: the build can only once per session.

I see that there exists special build task classes, namely AppDomainIsolatedTask but I can find no examples or evidence that this class can be utilized for an inline task.

Question:

Is it possible to run an Inline Build task in a separate AppDomain? If so, then how?

Side Node: Anyone else think its odd that a build task, which runs in MsBuild.exe causes both MsBuild.exe and DevEnv.exe to lock the file? Even if the persistent MsBuild.exe is killed, the previously loaded assembly is still locked.





Aucun commentaire:

Enregistrer un commentaire