更改 Visual Studio 的默认构建输出路径
是否有任何充分的理由修改项目的构建输出路径(从默认的“bin\debug”)?将解决方案中的所有项目指向公共构建输出位置有什么好处吗?
Are there any good reasons to modify your project's build output path from its default of "bin\debug"? Is there any benefit to pointing all your projects within a solution to a common build output location?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,我通常一直这样做。正如哈利所说,它减少了磁盘空间的使用。这对我来说确实不是什么大问题,因为磁盘空间非常便宜,但这可能是您关心的问题。我这样做的真正原因是为了更好地反映部署的样子。最好的方法是拥有一个 属性sheet 将输出目录修改为
$(SolutionDir)/build/bin
。之后,我将工作目录设置为$(SolutionDir)/build
,这是与将要部署的结构相同的整个结构,而不是将其分散在各个项目目录中。总的来说,为构建的东西(而不是源代码)建立一个独立的目录是一件好事。它简化了编写自定义构建步骤,因为您知道最终的输出将在哪里,并且简化了与版本控制系统的集成,因为您可以将其设置为忽略整个目录,而不是四处设置
ignore
对于所有.exe
、.lib
、.so
、.dll
以及每个小目录的任何内容。Yes, I typically do this all the time. As Harry said, it reduces disk space usage. That really is not a big deal to me, since disk space is incredibly cheap, but it might be a concern for you. The real reason I do it it to better mirror what the deployment will look like. The best way to do this is to have a property sheet which modifies the output directory to
$(SolutionDir)/build/bin
. After this, I set the working directory to$(SolutionDir)/build
, which is the whole structure which is identical to what would be deployed, rather than having it spread out among the various project directories.Overall, having an isolated directory for things that are built (rather than sources) is a good thing. It eases writing custom build steps, since you know where the ultimate output will be and eases integration with your version control system, since you can just set it to ignore that whole directory, rather than going around setting
ignore
for all.exe
,.lib
,.so
,.dll
and whatever for every little directory.我更改输出目录的主要原因是为了减少 Visual Studio 必须制作的重复程序集的数量和文件副本的数量。如果项目 A 引用项目 B,并且项目 C 引用项目 A 和 B,则 Studio 必须构建 A,将 A 复制到 B 并构建 B,然后将 A 和 B 复制到 C 并构建 C。您现在拥有程序集 A 的 3 个副本,程序集 B 的两份副本和 C 的一份副本。将输出指向单个目录,Visual Studio 只需构建 A,然后构建 B,然后构建 C。每个副本一份。您可以想象,随着项目数量和依赖项复杂性的增加,构建会消耗多少磁盘空间和时间。
The primary reason I change my output directory is to cut down on the number of duplicate assemblies and the number of file copies Visual Studio has to make. If project A references project B, and project C references project A and B then Studio has to build A, copy A to B and build B, then copy A and B to C and build C. You now have 3 copies of assembly A, two copies of assembly B, and one of C. Pointing the output to a single directory, Visual Studio simply builds A, then B, then C. One copy of each. You can imagine how much more disk space and time is consumed for a build as the number of projects and complexity of dependencies grows.
作为一个例子,我有一个 updater.exe 应该与“其他”程序一起分发。所以我将构建路径设置为“其他”程序构建路径。这样我就知道我总是拥有最新的“updater.exe”。
这只是原因之一。
As an example I have an updater.exe that is supposed to be distributed with an "other" program. So I set the build path to the "other" programs build path. That way I know i allways have the latest "updater.exe" where it should be.
Thats just one reason.