在新的 csproj 中的 nuget 包中添加自定义 DLL 文件

Add custom DLL files in nuget package in new csproj

.nuspec 文件有 部分,新 csproj 文件包含本地化资源的替代方案是什么?如何添加自定义DLL文件?

技巧的第一部分是将第三方 DLL 添加到 nupkg。这样做:

      <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>

如果您将此包安装到旧式 csproj 中,则会添加对 ThirdParty.dll 的引用。

但是,如果您将此包安装到新式 csproj 中,那么对 ThirdParty.dll 的引用将 而不是 添加为引用,这很烦人。工作进行中...