.net – Using a common library which contains MEF exports in multiple Visual Studio extensions


I am building a Visual Studio extension which uses a 3rd-party library (MonoDevelop.Xml to be specific). The library contains some MEF components intended to be used together with my custom components. So I have added the library into my VSIX manifest:

<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
    <!-- ... -->
    <Assets>
        <!-- ... -->
        <Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%.Xml.Editor" Path="|UnityModStudio.RimWorld.Xml.Editor|" />
        <Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="MonoDevelop.Xml.Editor" Path="|MonoDevelop.Xml.Editor|" />
    </Assets>
</PackageManifest>

So far, so good. I implemented a custom IAsyncCompletionSourceProvider in the UnityModStudio.RimWorld.Xml.Editor project and got my custom completions working as intended.

Then I decided to install the MonoDevelop.MSBuildEditor extension which also uses MonoDevelop.Xml into the experimental instance to see how some features should work and found that both extensions are not working. I found that I can make both extensions work together by removing the

<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="MonoDevelop.Xml.Editor" Path="|MonoDevelop.Xml.Editor|" />

line from my VSIX manifest, but then my extension stops working when MonoDevelop.MSBuildEditor is disabled.

What can I do on my end to make both extensions work together, but independently?

Leave a Reply

Your email address will not be published. Required fields are marked *