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
- Create a new VSIXProject
- Make sure "PackageReference" is enabled by default by selecting Tools > NuGet Package Manager > Package Manager Settings.. and setting "Default package management format" to "PackageReference".
- Right click on the VSIXProject and select "Manage NuGet packages"
- Add a NuGet package that has a DLL (e.g. NuGet.VisualStudio).
- 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>
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
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: