简体   繁体   中英

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 ( eg \\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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM