title: How to copy framework dependent (exe) file from PackageReference/Nuget Package to output directory?
body: <p>i have a multi-targeting project (net48;net6.0) which depends on a Nuget Package containing framework dependent files (lib/net6.0/Assembly.exe).
  I want to copy these files from the nuget package to the TargetFramework output directory (net6.0).</p>
  <p>I tried to add targets to the nuget package, but the target is only executed for the net48 build, not for the net6.0, because targets are only executed once overall (?).</p>
  <p>nuget package csproj contains:</p>
  <pre><code>&lt;ItemGroup&gt;
      &lt;None Include=&quot;$(AssemblyName).targets&quot; Pack=&quot;true&quot; PackagePath=&quot;build&quot; /&gt;
      &lt;None Include=&quot;$(OutputPath)net6.0\$(AssemblyName).exe&quot; Pack=&quot;true&quot; PackagePath=&quot;lib\net6.0&quot; Visible=&quot;false&quot; /&gt;
      &lt;None Include=&quot;$(OutputPath)net6.0\$(AssemblyName).runtimeconfig.json&quot; Pack=&quot;true&quot; PackagePath=&quot;lib\net6.0&quot; Visible=&quot;false&quot; /&gt;
    &lt;/ItemGroup&gt;
  </code></pre>
  <p>target project contains:</p>
  <pre><code>&lt;PackageReference Include=&quot;MyNugetpackage&quot; Version=&quot;1.0.0.0&quot;&gt;
      &lt;PrivateAssets&gt;all&lt;/PrivateAssets&gt;
      &lt;IncludeAssets&gt;runtime; build; native; contentfiles; analyzers; buildtransitive&lt;/IncludeAssets&gt;
  &lt;/PackageReference&gt;
  </code></pre>
  <p>I tried to add a .targets to the nuget package which currently contains:</p>
  <pre><code>&lt;Project xmlns=&quot;http://schemas.microsoft.com/developer/msbuild/2003&quot;&gt;
      &lt;ItemGroup Condition=&quot;'$(TargetFramework)'=='net6.0'&quot;&gt;
          &lt;None Include=&quot;$(MSBuildThisFileDirectory)..\lib\$(TargetFramework)\*.exe&quot; Visible=&quot;false&quot;&gt;
              &lt;CopyToOutputDirectory&gt;PreserveNewest&lt;/CopyToOutputDirectory&gt;
          &lt;/None&gt;
          &lt;None Include=&quot;$(MSBuildThisFileDirectory)..\lib\$(TargetFramework)\*.runtimeconfig.json&quot; Visible=&quot;false&quot;&gt;
              &lt;CopyToOutputDirectory&gt;PreserveNewest&lt;/CopyToOutputDirectory&gt;
          &lt;/None&gt;
      &lt;/ItemGroup&gt;
  
      &lt;Target Name=&quot;CopyNet6File&quot;
              Condition=&quot;'$(TargetFramework)'=='net6.0'&quot;
              BeforeTargets=&quot;CopyAdditionalFiles&quot;&gt;
          &lt;Copy SourceFiles=&quot;$(MSBuildThisFileDirectory)..\lib\$(TargetFramework)\*.exe&quot;
                DestinationFolder=&quot;$(TargetDir)&quot;
                Retries=&quot;10&quot;
                SkipUnchangedFiles=&quot;true&quot;
                OverwriteReadOnlyFiles=&quot;true&quot; /&gt;
  
          &lt;Copy SourceFiles=&quot;$(MSBuildThisFileDirectory)..\lib\$(TargetFramework)\*.runtimeconfig.json&quot;
                DestinationFolder=&quot;$(TargetDir)&quot;
                Retries=&quot;10&quot;
                SkipUnchangedFiles=&quot;true&quot;
                OverwriteReadOnlyFiles=&quot;true&quot; /&gt;
      &lt;/Target&gt;
  &lt;/Project&gt;
  </code></pre>
  <p>it doesn't work neither, nothing is copied.
  Hwo to execute targets for all TargetFrameworks - or - how to copy files for every TargetFrameworks from nuget package ?</p>
  <p>Any help really appreciated.
  Thank you very much.</p>