简体   繁体   English

C#和VS2015:编译时如何节省时间?

[英]C# & VS2015: How to save time when compiling?

So, I have a BIG project with lots of stuff in it, but when for example I fix the code, VS2015 compiles the whole project again which takes lots and lots of time. 因此,我有一个包含很多内容的BIG项目,但是例如,当我修复代码时,VS2015再次编译整个项目,这需要很多时间。 Can I somehow only compile the file I edited? 我可以只以某种方式编译我编辑的文件吗?
EDIT: I have one solution, in that I have one project, in that project I have lots of files. 编辑:我有一个解决方案,在我有一个项目,在那个项目中我有很多文件。

The Build process is smart, it will skip projects that haven't changed and for which the dependencies also haven't been changed. 生成过程很聪明,它将跳过未更改的项目以及也未更改依赖项的项目。 If you change something inside a library that is used by more or less the entire solution, then there just is no alternative but to rebuild all that was (potentially) touched. 如果您在某个库中更改了某种或多或少用于整个解决方案的库,那么别无选择,只能重建(可能)涉及的所有库。

You could try tuning the Dependencies yourself, right-click on the Solution and select 'Project dependencies...'. 您可以尝试自己调整依赖关系,右键单击解决方案,然后选择“项目依赖关系...”。 But you can't remove Dependencies that are needed or inferred. 但是您无法删除需要或推断的依赖项。

Get an SSD as build drive. 获取SSD作为构建驱动器。 A fast one. 快一个。

All the other tips given here are a given - build is smart, so it will only recompile what needs to be recompiled. 这里给出的所有其他技巧都是给定的-构建很聪明,因此它只会重新编译需要重新编译的内容。 This is hardly a help, though, if you have a base library that triggers dozens of projects to update. 但是,如果您拥有一个触发许多项目进行更新的基础库,那么这几乎没有帮助。

Compilation is IO limited, so a SSD helps 编译受IO限制,因此SSD可以帮助您

Otherwise it may be time to destroy that large solution and generate inernal NUGET packages of base libraries. 否则,可能是时候破坏该大型解决方案并生成基本库的内部NUGET包了。 This can decouple recompilations of base libraries and actual applications. 这可以使基础库和实际应用程序的重新编译脱钩。 This is particularly useful if you do maintenance on the base libraries. 如果您要对基础库进行维护,这将特别有用。

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

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