Publish Custom NuGet with referenced dll

In my project I have referenced a specific dll, which I have said to Copy local

But when the package is published the DLL is not in the NuGet package.
How do I make sure that whenever I click on Publish the referenced DLL is included?

@mdiv Please go through the below link. It would helpful

https://www.youtube.com/watch?v=p8GrdJHwHPw

@ushu thank you for the video link, but it isn’t telling anything about adding dlls to your NuGet package.

Below is my published packages, the one where I used NuGet packages DocumentFormat.OpenXML and OpenXmlPowerTools.
The problem is when I use OpenXmlPowerTools as referenced package in UiPath Studio my robot didn’t work. (I have spent hours on this, and also had UiPath support look into this)
If I include the dll files of the 2 packages, it works, but I need to manually add them to the published package using NuGet Package Explorer.

If I forget to add them manually the package wont work.

On another node I found this is the csproj code:

<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="BuildOnlySettings;ResolveReferences">
    <ItemGroup>
      <!--Filter out unnecessary files-->
      <_ReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')-&gt;WithMetadataValue('PrivateAssets', 'All'))" />
    </ItemGroup>

    <!--Print batches for debug purposes-->
    <Message Text="Batch for .nupkg: ReferenceCopyLocalPaths = @(_ReferenceCopyLocalPaths), ReferenceCopyLocalPaths.DestinationSubDirectory = %(_ReferenceCopyLocalPaths.DestinationSubDirectory) Filename = %(_ReferenceCopyLocalPaths.Filename) Extension = %(_ReferenceCopyLocalPaths.Extension)" Importance="High" Condition="'@(_ReferenceCopyLocalPaths)' != ''" />

    <ItemGroup>
      <!--Add file to package with consideration of sub folder. If empty, the root folder is chosen.-->
      <BuildOutputInPackage Include="@(_ReferenceCopyLocalPaths)" TargetPath="%(_ReferenceCopyLocalPaths.DestinationSubDirectory)" />
    </ItemGroup>
  </Target>

As far as I can read, it should copy the referenced files over, but I don’t really understand how this works.
I also been looking into this: Quickstart: Create and publish a NuGet package using Visual Studio (Windows only) | Microsoft Learn

Solution was actually simple if you just know how to do it :smiley:

I just added the files under ItemGroup using this guide: Quickstart: Create and publish a NuGet package using Visual Studio (Windows only) | Microsoft Learn

  <ItemGroup>
    <None Remove="Designers\xxx.xaml" />
    <None Include="..\..\Logo.png">
      <Pack>True</Pack>
      <PackagePath></PackagePath>
    </None>
    <Content Include="DocumentFormat.OpenXml.dll">
      <Pack>True</Pack>
      <PackagePath>\lib\net461</PackagePath>
    </Content>
    <Content Include="OpenXmlPowerTools.dll">
      <Pack>True</Pack>
      <PackagePath>\lib\net461</PackagePath>
    </Content>
  </ItemGroup>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.