visual-studio 为什么每次我点击“播放”时 VS 都必须重建我的所有项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1480008/
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
Why does VS have to rebuild ALL of my projects every time I hit "Play"?
提问by skb
Do I have some weird setting that is making this happen? I only want to change the text of a message box (and no other assemblies depend on that one) yet VS rebuilds all of my projects and it takes forever. Any ideas?
我是否有一些奇怪的设置导致这种情况发生?我只想更改消息框的文本(并且没有其他程序集依赖于该消息框),但 VS 重建了我的所有项目并且需要永远。有任何想法吗?
采纳答案by Quintin Robinson
You can exclude projects from your general build through the build menu..
您可以通过构建菜单从常规构建中排除项目。
Build → Configuration Manager → Uncheck projects that you don't want to always build.
构建 → 配置管理器 → 取消选中您不想始终构建的项目。
This can massively speed up build time by only building projects that absolutely need to be built every time.
这可以通过只构建每次都绝对需要构建的项目来大大加快构建时间。
Note though you will have to build the projects that you've unselected independently (right click->Build on the project etc) if they need to be rebuilt.
请注意,如果需要重建,您必须独立构建您未选择的项目(右键单击-> 在项目上构建等)。
You can also setup alternate build configurations so you can mix and match what will build when.
您还可以设置备用构建配置,以便混合和匹配将在何时构建。
回答by Mark Meuer
You can find out what is causing Visual Studio to think each project is out of date, and then address the issue directly.
您可以找出导致 Visual Studio 认为每个项目已过期的原因,然后直接解决问题。
- Select Tools → Options → Projects and Solutions → Build and Run.
- For the setting "MSBuild project build output verbosity:" select "Diagnostic".
- Build.
- 选择工具 → 选项 → 项目和解决方案 → 构建和运行。
- 对于设置“MSBuild 项目构建输出详细程度:”选择“诊断”。
- 建造。
You will get a hugeamount of output in the output window detailing exactly what the build is doing. Before building each project it will print out why it thinks it is out of date. An example of such output is:
您将在输出窗口中获得大量输出,详细说明构建正在做什么。在构建每个项目之前,它会打印出为什么它认为它已经过时。这种输出的一个例子是:
Project 'Foo' is not up to date. Input file 'c:\Bar.cs' is modified after output file
These "not up to date" messages should point you to the real cause of the unnecessary builds, which you can then fix.
这些“不是最新的”消息应该让您指出不必要构建的真正原因,然后您可以修复这些原因。
回答by womp
There's some limited control over this without using Configurations if you check the option to only build startup projects and dependencies on Run.
如果您选中仅在 Run 上构建启动项目和依赖项的选项,则在不使用 Configurations 的情况下对此进行一些有限的控制。
Tools → Options → Projects and Solutions → Build and Run → Only build startup projects and dependencies on Run
工具 → 选项 → 项目和解决方案 → 构建和运行 → 仅在运行上构建启动项目和依赖项
回答by JaredPar
The play button is the start debugging feature.
播放按钮是启动调试功能。
Yes, Visual Studio will ask every project in the solution to build at that point. But note asking to build and actually building are different things. Asking to build merely says, about to do something build again if you would like. MsBuild will then do a bit of checking under the hood and decide if it should actually build the underlying project.
是的,Visual Studio 会要求解决方案中的每个项目在那时构建。但请注意,要求构建和实际构建是不同的事情。要求构建只是表示,如果您愿意,可以重新构建一些东西。MsBuild 然后会在幕后做一些检查,并决定它是否应该真正构建底层项目。
If your project is actually building then there may be some other problem going on. Can you give us some more info like language, project type, etc ...
如果您的项目实际上正在构建,那么可能存在其他一些问题。你能给我们一些更多的信息,比如语言、项目类型等......
回答by RedFury
It's also possible to change the setting 'On Run, when projects are out of date'to 'Never Build'instead of 'Ask'. (its in the menu 'Tools -> Options -> Projects & Solutions -> Build & Run) This way, you'd need to press F6 every time you make a change to build the out-of-date projects, but at least it will allow you to debug with F5 without the recompile.
也可以将设置“运行时,当项目过期时”更改为“从不构建”而不是“询问”。(它在菜单“工具 -> 选项 -> 项目和解决方案 -> 构建和运行”中)这样,每次进行更改以构建过时的项目时,您都需要按 F6,但至少它将允许您在不重新编译的情况下使用 F5 进行调试。
I have to say this is not ideal, but it's something. There was one issue though I had while using casini: The app-pool didn't recyle every time I press F5 because casini keeps running. You will have to manually stop casini from the icontray when you encouter problems but it's a major time-saver in contrast to rebuilding the entire site.
我不得不说这并不理想,但确实如此。虽然我在使用 casini 时遇到了一个问题:应用程序池不会在我每次按 F5 时回收,因为 casini 一直在运行。当您遇到问题时,您将不得不从图标托盘中手动停止 casini,但与重建整个站点相比,它可以节省大量时间。
回答by Jed Smith
The "Play" button is probably not what you think it is, or you have incremental linking and the like turned off in your Project Settings.
“播放”按钮可能不是您认为的那样,或者您在项目设置中关闭了增量链接等。

