locked
How to add referenced DLLs to VSIX? RRS feed

  • Question

  • Hi,

    I have an Extension for Visual Studio which compiles into a VSIX container. There are plenty of referenced DLL for which I've set the "copy local" property to true. I want that those dlls are also part of the VSIX, but they are not. Interestingly, I never had this issue until I switched to VS2015. Have there been any changes regarding how/which dlls are added to VSIX? How can I get my "copy local" dlls to be part of the VSIX container?

    Thanks & Regards,
    Max

    Tuesday, February 9, 2016 1:44 PM

Answers

  • By default referenced dlls with Copy Local = true are included in the .vsix. Test this:

    - Create New Project > Visual C#> Extensibility > VSIX Project

    - Add New Item > Visual C# Items > Extensibility > Visual Studio Package

    - Add a reference to ClassLibrary1.dll that you create in a separate VS instance and solution. The referenced dll has by default Copy Local = true

    - Build the solution.

    - Go to the Bin\Debug folder

    - Rename VSIXProject1.vsix to VSIXProject1.zip and open it. ClassLibrary1.dll is included.

    That said, the MSBuild target that handles that is Microsoft.VsSDK.targets and is in this folder:

    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\VSSDK

    The behavior is controlled by the IncludeCopyLocalReferencesInVSIXContainer property that by default is true:

    <IncludeCopyLocalReferencesInVSIXContainer Condition="'$(IncludeCopyLocalReferencesInVSIXContainer)'==''">true</IncludeCopyLocalReferencesInVSIXContainer>

    Search the CreateVsixSourceItemFromReferences target and notice that its SuppressedVSIXSourceItems parameter has tons of excluded dlls


    My portal and blog about VSX: http://www.visualstudioextensibility.com
    Twitter: https://twitter.com/VSExtensibility
    MZ-Tools productivity extension for Visual Studio: http://www.mztools.com

    • Marked as answer by f_max Thursday, February 11, 2016 9:28 AM
    Thursday, February 11, 2016 7:16 AM

All replies

  • Hi Max,

    - Open or edit the .vsixmanifest file of your package project

    - Go to Assets section

    - Click the New button

    - Select Type: Microsoft.VisualStudio.Assembly

    - Select Source: File on filesystem


    My portal and blog about VSX: http://www.visualstudioextensibility.com
    Twitter: https://twitter.com/VSExtensibility
    MZ-Tools productivity extension for Visual Studio: http://www.mztools.com


    Tuesday, February 9, 2016 4:16 PM
  • Hi,

    thanks for the response. I know about this already, but it has the disadvantage that I need to add all referenced DLLs manually. In contrast, I want Visual Studio to automatically add all dlls (which are marked as "copy local") to the VSIX container. This worked fine so far, but VS2015 somehow seems to behave differently.

    Regards,
    Markus

    Wednesday, February 10, 2016 11:57 AM
  • By default referenced dlls with Copy Local = true are included in the .vsix. Test this:

    - Create New Project > Visual C#> Extensibility > VSIX Project

    - Add New Item > Visual C# Items > Extensibility > Visual Studio Package

    - Add a reference to ClassLibrary1.dll that you create in a separate VS instance and solution. The referenced dll has by default Copy Local = true

    - Build the solution.

    - Go to the Bin\Debug folder

    - Rename VSIXProject1.vsix to VSIXProject1.zip and open it. ClassLibrary1.dll is included.

    That said, the MSBuild target that handles that is Microsoft.VsSDK.targets and is in this folder:

    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\VSSDK

    The behavior is controlled by the IncludeCopyLocalReferencesInVSIXContainer property that by default is true:

    <IncludeCopyLocalReferencesInVSIXContainer Condition="'$(IncludeCopyLocalReferencesInVSIXContainer)'==''">true</IncludeCopyLocalReferencesInVSIXContainer>

    Search the CreateVsixSourceItemFromReferences target and notice that its SuppressedVSIXSourceItems parameter has tons of excluded dlls


    My portal and blog about VSX: http://www.visualstudioextensibility.com
    Twitter: https://twitter.com/VSExtensibility
    MZ-Tools productivity extension for Visual Studio: http://www.mztools.com

    • Marked as answer by f_max Thursday, February 11, 2016 9:28 AM
    Thursday, February 11, 2016 7:16 AM
  • Thanks for the Hint! As you pointed out, in VS2015 there are tons of excluded DLLs (SuppressedVSIXSourceItems) - this has changed since e.g. VS2012 and that was exactly the problem I was having: There were plenty of DLLs not included in the VSIX any more due to the SuppressedVSIXSourceItems-Attribute.
    Thursday, February 11, 2016 9:31 AM
  • Notice that the excluded dlls are excluded for a good reason: they are provided by Visual Studio on the target machine and your .vsix should not include them. Maybe even they are not legally redistributable.

    My portal and blog about VSX: http://www.visualstudioextensibility.com
    Twitter: https://twitter.com/VSExtensibility
    MZ-Tools productivity extension for Visual Studio: http://www.mztools.com

    Thursday, February 11, 2016 11:11 AM
  • It's a heavy pitfall, since in VS2017 it even excludes common NuGet packages, like e.g. Newtonsoft.Json.dll or System.Collections.Immutable.dll - independent of it's version!.

    Once you update such packages to the latest version, you extension will crash because it can't load the older dlls included in VS.

    Sunday, December 10, 2017 4:20 PM
  • I have created a related question: Newtonsoft.Json.dll not included in VSIX. This may be a case of the "heavy pitfall"

    Friday, February 23, 2018 3:56 AM