简体   繁体   English

MsBuild目标,将项目依赖项复制到目标目录

[英]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 ). MsBuild目标中的哪个目标将项目依赖项(引用的项目依赖项)复制到目标目录(例如\\ 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 MsBuild目标列表: https ://gist.github.com/StevenLiekens/cae70cce25344ba47b86

but I would like to know the closest target that does it. 但我想知道最接近的目标。

That should be the target _CopyFilesMarkedCopyLocal . 那应该是目标_CopyFilesMarkedCopyLocal

https://gist.github.com/StevenLiekens/cae70cce25344ba47b86#file-target-xml-L93 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: 您可以创建两个测试空白项目,项目A引用项目B,然后将MSBuild项目的生成输出详细程度更改为“ 详细”或“ 诊断” (“ Tools ->“ Options ->“ Projects and Solutions - >Build and Run ->“ MSBuild project build output verbosity >Build and Run MSBuild project build output verbosity ,生成项目A,在输出窗口的生成日志中,您将找到有关项目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. 就像我们知道的那样,如果我们引用一个项目, Copy Local引用项目的“ Copy Local ”属性将设置为True,在我们构建该项目时,该引用将被复制到目标目录。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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