0

I have more than 100 projects in my solution, now I have to add a post-build event to most of projects to copy some unmanaged 3rd party assemblies into its $(TargetDir), but I have to add this post-build event to those projects one by one, which is not what I want. So I want to know if there is a way to resolve this issue without having to add event for most projects one by one.

1 Answers1

1

Add build event to multiple projects without adding one by one

You can add the copy target into the Directory.Build.props file and set this .props in the solution directory. If a props file is called Directory.Build.props it will be automatically imported to into all projects in the directory hierarchy.

Below in my Directory.Build.props:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="CopySAssembly" AfterTargets="Build">
      <Message Text="YourCopyTask"></Message>
    </Target>
</Project>

Alternatively, you can use nuget package to manage those unmanaged 3rd party assemblies, add this nuget package to the multiple projects should be very easy, using nuget package manager for solution:

Create nuget package from dlls

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135