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

hVo*_*stt 5 csproj nuget nuget-package

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

Ric*_*ugh 1

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

      <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>
Run Code Online (Sandbox Code Playgroud)

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

但是,如果您将此包安装到新型 csproj 中,那么对的引用将ThirdParty.dll不会添加为引用,这令人恼火。工作正在进行中...