2
votes

I am using MEF to do a sort of crude plugin architecture. This is working well. However, when I do a deployment using the visual studio package/publish build tasks (which I am calling via NAnt/MSbuild). My unreferenced plugin assemblies are not being included in the package and so are not deployed.

Is there a way to tell VS/MSBuild to include these DLLs?

They live in /bin/Extensions.

Cheers, Rob

3

3 Answers

3
votes
  • Add the assemblies as links in the project where you want them copied: right lick on the project -> Add -> Existing Item -> select the assembly. Instead of just clicking Add, click on the arrow besides it and select "Add As Link"
  • Select the linked assembly in the solution explorer -> open properties if it isn't opened:
    • Build Action: None
    • Copy to Output Directory: Copy always or Copy if newer

By doing the above the assemblies are still physically where you had them originally (I assume a references folder) and when you build those are copied to the bin folder.

2
votes

I have found the answer in this blog post. It works perfectly: http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx

Basically here's the code I added to my project file.

<!--
    Added by RSL to deal with deploying the plugins folder
    Followed tutorial here:
    http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx
  -->
    <PropertyGroup>
        <CopyAllFilesToSingleFolderForPackageDependsOn>
            CollectExtensionDLLs;
            CollectExtensionViews;
            $(CopyAllFilesToSingleFolderForPackageDependsOn);
        </CopyAllFilesToSingleFolderForPackageDependsOn>
    </PropertyGroup>
    <Target Name="CollectExtensionDLLs">
        <ItemGroup>
            <_CustomFiles Include="bin\Extensions\**\*"/>

            <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
                <DestinationRelativePath>bin\Extensions\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
            </FilesForPackagingFromProject>
        </ItemGroup>
    </Target>
    <Target Name="CollectExtensionViews">
        <ItemGroup>
            <_CustomFiles Include="Views\Extensions\**\*"/>

            <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
                <DestinationRelativePath>Views\Extensions\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
            </FilesForPackagingFromProject>
        </ItemGroup>
    </Target>
    <!-- //// End Rob's modifications -->