C# 自己的组件生成Nuget包,组件里的内容(dll等)设置了复制到输出目录,但是引用该Nuget包后生成路径并没有相应的内容

例如组件A项目中想把以下dll拷贝都输出目录,

 已经设置了复制到输出目录。

然后项目B通过Nuget包引入了组件A,然后项目B生成路径下并没有这几个opencv的dll。

经过组内大佬 唐宋元明清2188 的研究

需要在组件A的项目文件中给每个dll内容连接添加

<PackageCopyToOutput>true</PackageCopyToOutput>
<ItemGroup>
    <Content Include="dll\x64\OpenCvSharpExtern.dll">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        <PackageCopyToOutput>true</PackageCopyToOutput>
    </Content>
    <Content Include="dll\x64\opencv_ffmpeg400_64.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    <PackageCopyToOutput>true</PackageCopyToOutput>
    </Content>
    <Content Include="dll\x86\OpenCvSharpExtern.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    <PackageCopyToOutput>true</PackageCopyToOutput>
    </Content>
    <Content Include="dll\x86\opencv_ffmpeg400.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    <PackageCopyToOutput>true</PackageCopyToOutput>
    </Content>
  </ItemGroup>

 

posted @ 2023-09-27 17:06  log9527  阅读(113)  评论(0编辑  收藏  举报