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

时间:2018-08-21 10:36:00

标签: .net visual-studio msbuild

MsBuild目标中的哪个目标将项目依赖项(引用的项目依赖项)复制到目标目录(例如\ bin \ Debug)。当然,它可能是编译目标,但我想知道最接近的目标。

MsBuild目标列表: https://gist.github.com/StevenLiekens/cae70cce25344ba47b86

1 个答案:

答案 0 :(得分:1)

  

但是我想知道最接近的目标。

那应该是目标_CopyFilesMarkedCopyLocal

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

您可以创建两个测试空白项目,项目A引用项目B,然后将MSBuild项目生成的输出详细程度更改为详细诊断({{1} > Tools –> OptionsProjects and Solutions-> >Build and Run),构建项目A,在输出窗口的构建日志中,您会找到以下关于项目A的消息:

MSBuild project build output verbosity

就我们所知,如果我们引用一个项目,则所引用项目的属性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". 将设置为True,在我们构建该项目时,该引用将被复制到目标目录。

希望这会有所帮助。