algorytmus
algorytmus

Reputation: 973

MsBuild target that copies project dependencies into target dir

Which Target from the MsBuild targets copies project dependencies ( referenced projects dependencies ) to the target dir ( e.g. \bin\Debug ). Sure it might be Compile target but I would like to know the closest target that does it.

MsBuild targets list: https://gist.github.com/StevenLiekens/cae70cce25344ba47b86

Upvotes: 0

Views: 2111

Answers (1)

Leo Liu
Leo Liu

Reputation: 76740

but I would like to know the closest target that does it.

That should be the target _CopyFilesMarkedCopyLocal.

https://gist.github.com/StevenLiekens/cae70cce25344ba47b86#file-target-xml-L93

You can create two test blank projects, project A refer project B, then change the MSBuild project build output verbosity to Detailed or Diagnostic(Tools –>Options –>Projects and Solutions>Build and Run-> MSBuild project build output verbosity), build the project A, in the build log on the output window, you will find following message for project A:

2>Target "_CopyFilesMarkedCopyLocal" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets" from project "c:\users\xxx\source\repos\ClassLibrary2\ProjectA\ProjectA.csproj" (target "CopyFilesToOutputDirectory" depends on it):
2>Task "Copy"
2>  Copying file from "c:\users\xxx\source\repos\xxxx\ProjectB\bin\Debug\ProjectB.dll" to "bin\Debug\ProjectB.dll".
2>  Copying file from "c:\users\xxx\source\repos\xxxx\ProjectB\bin\Debug\ProjectB.pdb" to "bin\Debug\ProjectB.pdb".
2>Done executing task "Copy".
2>Using "Touch" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
2>Task "Touch"
2>  Creating "c:\users\xxx\source\repos\ClassLibrary2\ProjectA\obj\Debug\ProjectA.csproj.CopyComplete" because "AlwaysCreate" was specified.
2>Done executing task "Touch".
2>Done building target "_CopyFilesMarkedCopyLocal" in project "ProjectA.csproj".

Just as we know it, if we reference a project, the property Copy Local of the referenced project will be set to True, when we build the project, this reference will be copy to the target dir.

Hope this helps.

Upvotes: 3

Related Questions