How to set output subfolder to copy reference dll to on build

1k Views Asked by At

Project References dlls are copied on build to the root of output directory (if <Private>True</Private> is set for this reference at .csproj, or Copy Local is set to True at reference properties in VisualStudio)

I have NuGet-package dependency of some 3rd-party dll & want this dll to be copied to some subfolder of output dir on build. How can this be done?

PS: I've seen this question. But there is no answer appropriate for my case.

1

There are 1 best solutions below

0
user1234567 On

I didn't find better way, than just let them be coppied to output root & then move them to my subfolder by adding this instruction to .csproj:

  <!-- Move some dlls into /MySubfolder -->
  <PropertyGroup>
    <PrepareForRunDependsOn>$(PrepareForRunDependsOn);MyMoveDllsToOutputSubdir</PrepareForRunDependsOn>
  </PropertyGroup>
  <Target Name="MyMoveDllsToOutputSubdir">
    <Move SourceFiles="$(OutDir)\Aaa.dll;$(OutDir)\Aaa.pdb" DestinationFolder="$(OutDir)\MySubfolder" />
  </Target>