ClickOnce include imported .targets when publishing (FFMPEG)

I have a WinForms application which I am publishing via ClickOnce. This applciation includes the Accord FFMPEG libraries, which are included as references.

The FFMPEG NuGet package folder includes a .targets file, which includes a variety of dlls needed for proper operation of the FFMPEG library (avcodec.dll, avformat.dll, avutil.dll). These are copied to the bin folder when building the project. This is done by including this line in the .csproj:

Import Project="..packagesAccord.Video.FFMPEG.3.3.0buildAccord.Video.FFMPEG.targets" Condition="Exists('..packagesAccord.Video.FFMPEG.3.3.0buildAccord.Video.FFMPEG.targets')" 

However when publishing the application via ClickOnce, these files are not included in the published folder. Is there a way to run the Import Project task and add the files into the published folder?


Unfortunately I didn't manage to get this working using the .targets file. My solution in the end was to copy the required dlls to the deployment folder and include them in the manifest, as below.

  <ItemGroup Label="FFMPEG DLL">
    <ClickOnce Include="..packagesAccord.Video.FFMPEG.3.3.0build*.dll">
      <InProject>false</InProject>
      <Visible>false</Visible>
    </ClickOnce>
  </ItemGroup>

  <Target Name="BeforeBuild">
    <CreateItem Include="@(ClickOnce)" AdditionalMetadata="TargetPath=%(FileName)%(Extension);IsDataFile=false">
      <Output TaskParameter="Include" ItemName="_DeploymentManifestFiles" />
    </CreateItem>
  </Target>

  <Target Name="BeforePublish">
    <Touch Files="@(IntermediateAssembly)" />
  </Target>

This is using .NET 4.6.1 and VS2017.

链接地址: http://www.djcxy.com/p/65996.html

上一篇: 如何反序列化XML文档

下一篇: ClickOnce在发布时包含导入的.targets(FFMPEG)