Search code examples
nugetnuget-packagecsproj

Add custom DLL files in nuget package in new csproj


.nuspec file has section <files>, what are the alternatives for include localization resources for new csproj file? How to add custom DLL files?


Solution

  • The first part of the trick is to get your third party DLL added to the nupkg. This does it:

          <ItemGroup>
        <Reference Include="ThirdParty">
          <HintPath>..\DLLs\ThirdParty.dll</HintPath>
        </Reference>
      </ItemGroup>
      <ItemGroup>
        <Content Include="$(OutputPath)\ThirdParty.dll">
          <Pack>true</Pack>
          <PackagePath>lib\$(TargetFramework)</PackagePath>
        </Content>
      </ItemGroup>
    

    If you install this package into an old-style csproj then a reference to ThirdParty.dll will be added.

    However, if you install this package into a new-style csproj then a reference to ThirdParty.dll will not be added as a referece, irritatingly. Work in progress...