Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying MEF component and VS package in the same project

I have one project, which needs to be of two components- a MEF component and a VSPackage. However, I haven't had much luck convincing Visual Studio to load the VSPackage from my VSIX. Here's the .vsixmanifest that I am using:

<?xml version="1.0" encoding="utf-8"?>
<Vsix Version="1.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2010">
    <Identifier Id="VisualWide.Microsoft.03ab796d-a0e5-440d-87f9-9461dec10f23">
        <Name>Visual Wide</Name>
        <Author>Fuckin' Magnets</Author>
        <Version>1.0</Version>
        <Description>Provides Wide support for Visual Studio</Description>
        <Locale>1033</Locale>
        <SupportedProducts>
            <VisualStudio Version="11.0">
                <Edition>VST_All</Edition>
                <Edition>Pro</Edition>
            </VisualStudio>
        </SupportedProducts>
        <SupportedFrameworkRuntimeEdition MinVersion="4.5" MaxVersion="4.5" />
    </Identifier>
    <Content>
        <MefComponent>|VisualWide|</MefComponent>
        <VsPackage>VSPackage/VSPackage1.pkgdef</VsPackage>
    </Content>
</Vsix>

The .pkgdef I took mostly from the wizard-generated VSPackage project.

[$RootKey$\InstalledProducts\VSPackage1Package]
@="#110"
"Package"="{27d97bf0-ec8c-466d-b1a0-df926943c05e}"
"PID"="1.0"
"ProductDetails"="#112"
"LogoID"="#400"
[$RootKey$\Packages\{27d97bf0-ec8c-466d-b1a0-df926943c05e}]
@="VSPackage1Package"
"InprocServer32"="$WinDir$\SYSTEM32\MSCOREE.DLL"
"Class"="Microsoft.VSPackage1.VSPackage1Package"
"CodeBase"="$PackageFolder$\VisualWide.dll"

I changed the CodeBase element to refer to the DLL my project generates.

I used the /log switch, and inspected the ActivityLog, and my pkgdef is indeed being found and loaded.

However, there's no evidence that my VSPackage is functioning. The default VSPackage from the tutorial has a log command in the constructor and initializer which should go to the debug output, but the log message doesn't appear. The Visual Studio about page doesn't list it. I placed breakpoints in the constructor and initialize(), and they are not hit.

How can I package my VSPackage so that it's loaded with my MEF component?

like image 465
Puppy Avatar asked Oct 21 '22 23:10

Puppy


1 Answers

If you want your package to load on Visual Studio startup, add the UICONTEXT_NoSolution attribute to your main Package class:

    [ProvideAutoLoad("ADFC4E64-0397-11D1-9F4E-00A0C911004F")]

Otherwise the package is loaded only when its commands or services are invoked by a user or other modules.

like image 196
Sergey Vlasov Avatar answered Nov 17 '22 02:11

Sergey Vlasov