visual-studio 更改 Visual Studio 的默认构建输出路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2603795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing Visual Studio's default build output path
提问by JC.
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?
是否有充分的理由将项目的构建输出路径从默认的“bin\debug”修改?将解决方案中的所有项目指向公共构建输出位置是否有任何好处?
采纳答案by Travis Gockel
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 sheetwhich 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.
是的,我通常做所有的时间。正如哈利所说,它减少了磁盘空间的使用。这对我来说真的没什么大不了的,因为磁盘空间非常便宜,但您可能会担心。我这样做的真正原因是为了更好地反映部署的样子。最好的方法是使用属性表将输出目录修改为$(SolutionDir)/build/bin. 在此之后,我将工作目录设置为$(SolutionDir)/build,这是与将要部署的内容相同的整个结构,而不是将其分散在各个项目目录中。
build
|-- bin
| |-- foo.exe
| |-- libfoo.dll
| `-- libbar.dll
|-- plugins
| |-- extender.py
| `-- something.lua
`-- skins
|-- default.skin
`-- white-and-gold.skin
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 ignorefor all .exe, .lib, .so, .dlland whatever for every little directory.
总的来说,为构建的东西(而不是源代码)建立一个独立的目录是一件好事。它简化了编写自定义生成步骤,因为你知道最终的输出将是与你的版本控制系统EASES整合,因为你可以将其设置为忽略整个目录,而不是四处设置ignore为所有.exe,.lib,.so,.dll和任何的每一个小目录。
回答by Harry Steinhilber
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.
我更改输出目录的主要原因是减少重复程序集的数量和 Visual Studio 必须制作的文件副本数量。如果项目 A 引用项目 B,项目 C 引用项目 A 和 B,那么 Studio 必须构建 A,将 A 复制到 B 并构建 B,然后将 A 和 B 复制到 C 并构建 C。您现在有 3 个程序集 A 的副本,程序集 B 的两个副本和 C 的一个副本。将输出指向单个目录,Visual Studio 只需构建 A,然后是 B,然后是 C。每个副本一个。您可以想象随着项目数量和依赖项复杂性的增加,构建会消耗多少磁盘空间和时间。
回答by Stefan
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.
例如,我有一个应该与“其他”程序一起分发的 updater.exe。所以我将构建路径设置为“其他”程序构建路径。这样我知道我总是有最新的“updater.exe”应该在哪里。
Thats just one reason.
这只是一个原因。

