Skip to content

NuGet packages referenced via PackageReference don't include DLLs in VSIX #5899

@AlexEyler

Description

@AlexEyler

Summary

When building a VSIX that references NuGet packages, users used to be able to easily include the assembly included in the NuGet packages by setting to true on the reference. The VSSDK build tasks search through the @(ReferencePath) item for any reference that has CopyLocal set to true and then includes
those references in the VSIX.

PackageReferences don't give the option to the user to set CopyLocal to true, so it's difficult for the average user to get a NuGet reference included in a VSIX.

I've attached a binary log from a build of a VSIX that's created via the repro steps. Let me know if you need any info - we're willing to make changes in the VSSDK to support this if need be (as long as the changes are backwards compatible, of course).
msbuild.zip

Repro steps

  1. Create a new VSIXProject
  2. Make sure "PackageReference" is enabled by default by selecting Tools > NuGet Package Manager > Package Manager Settings.. and setting "Default package management format" to "PackageReference".
  3. Right click on the VSIXProject and select "Manage NuGet packages"
  4. Add a NuGet package that has a DLL (e.g. NuGet.VisualStudio).
  5. Build the VSIXProject.
    Expected: NuGet.VisualStudio.dll is included in the VSIX.
    Actual: The VSIX does not contain NuGet.VisualStudio.dll.

Workaround

A workaround is available for VSIX developers:

<Target Name="IncludePackageReferenceDependencies" AfterTargets="GetVsixSourceItems">
  <ItemGroup>
    <VSIXSourceItem Include="@(ReferencePath)" Condition="$([System.String]::new('%(ReferencePath.FusionName)').StartsWith('NuGet.VisualStudio'))" />
  </ItemGroup>
</Target>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions