问题描述
我有9个项目的解决方案.每个项目中的所有引用的CopyLocal属性都设置为False.
I have a solution with 9 projects. All references in each project have their CopyLocal property set to False.
当我从VS构建它时,这些引用的二进制文件都不会复制到输出构建目录中.同样,当我使用msbuild进行构建时,我只会看到项目二进制文件,而没有引用.
When I build it from VS, none of these referenced binaries are copyed to the output build directory. Similarly, when I build using msbuild, I only see the project binaries and no references.
但是,当我在msbuild命令中指定输出路径时,会复制一些引用,但我不知道为什么?有没有我忘记设置的设置?有人看过吗?
However, when I specify an output path in the msbuild command, some references are copied and I don't know why? Is there some setting I am forgetting to set? Has anyone seen this before?
推荐答案
在不设置OutDir
属性的情况下构建应用程序时,文件将复制到项目属性中指定的路径("Build \ Output"路径).此后,还有另一个步骤将引用的项目输出(* .dll文件)复制到应用程序(* .exe)的OutDir
中.但是,如果将CopyLocal
设置为false,则不会发生最后一步.像这样:
When you build your application without setting the OutDir
property, the files are copied to the path specified in project properties (Build\Output path). After this, there is another step that copies the referenced project output (*.dll file) to the OutDir
of your application (*.exe). But if you set CopyLocal
to false, this last step doesn't happen. Like this:
ProjectEXE\OutDir = c:\a\bin
ProjectDLL\OutDir = c:\b\bin
请注意两个OutDir
是不同的(并且在项目属性中指定的不同)的事实.
Pay attention to the fact that the two OutDir
are different (and differently specified in your projects properties).
但是,当您使用命令提示符设置OutDir
时,会将两个OutDir
参数设置为同一路径.仍然没有将DLL的最终副本复制到应用程序的同一目录中,除了它与您首次构建DLL和EXE的位置相同.像这样:
But when you set the OutDir
using the command-prompt, you are setting both OutDir
parameters to the same path. Still there is no final copy of the DLL to the same directory of your application, except for the fact that it is the same location you built the DLL and EXE first time. Like this:
msbuild yourSolution.sln /p:OutDir="c:\a\bin\"
ProjectEXE\OutDir = c:\a\bin
ProjectDLL\OutDir = c:\a\bin
这篇关于输出路径和MSBuild的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!