visual-studio 当有代码更改时,Visual Studio 2010 不会在运行之前构建

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2646858/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:46:45  来源:igfitidea点击:

Visual Studio 2010 isn't building before a run when there are code changes

visual-studiovisual-studio-2010builddebugging

提问by jamone

I've been using using F5 (Start Debugging) for years to build the code (if its out of date), and then debug. This was working on VS 2010 also, however today it just start debugging without a build. Say I do a clean on the project, and then hit F5 instead of building it so it can run it throws an error message saying that the exe doesn't exist to run. How do I make it build first? What could have changed?

多年来,我一直在使用 F5(开始调试)来构建代码(如果它已经过时),然后进行调试。这也适用于 VS 2010,但是今天它只是在没有构建的情况下开始调试。假设我对项目进行了清理,然后按 F5 而不是构建它,以便它可以运行它会抛出一条错误消息,指出该 exe 不存在运行。我如何使它首先构建?什么可以改变?

回答by Hans Passant

Tools + Options, Projects and Solutions, Build and Run. "On Run, when projects are out of date" = Always build. The one below that = Do not launch.

工具 + 选项、项目和解决方案、构建和运行。“在运行时,当项目过时”= 始终构建。下面的那个=不要启动。

回答by Tim

I had this problem and it turned out to be the Configuration Manager. I had recently changed from Debug|Mixed CPU to Debug|Any CPU and the project wasn't set to build under this configuration

我遇到了这个问题,结果是配置管理器。我最近从 Debug|Mixed CPU 更改为 Debug|Any CPU 并且该项目未设置为在此配置下构建

回答by Michael Scherf

open your configuration manager and check out if the checkbox in the build column for your startup project is checked. I had the same problem, but the checkbox wasn't active, so i checked it and now it works!

打开您的配置管理器并检查是否选中了启动项目的构建列中的复选框。我遇到了同样的问题,但复选框未激活,所以我检查了它,现在它可以工作了!

回答by Alo

Apart from the above also make sure that 'Only build startup projects and dependencies on run' is unchecked (in Tools-->Options-->Projects and Solutions-->Build and Run)

除上述内容外,还要确保取消选中“仅在运行时构建启动项目和依赖项”(在工具--> 选项--> 项目和解决方案--> 构建和运行中)

回答by Vinnie

I had this problem too. I checked everything suggested to no avail. It turns out my clock on my pc had gotten set forward by about 12 hours, and I was saving to a network drive. The timestamps of the files were out of wack, and VS didn't think it needed to build my project because the files were super up to date.

我也有这个问题。我检查了所有建议无济于事。结果我电脑上的时钟已经提前了大约 12 个小时,我正在保存到网络驱动器。文件的时间戳不正常,VS 认为不需要构建我的项目,因为文件是最新的。

回答by Jeggs

For a while now I have alwasy been confused as to why my laptop (dual core 2ghz, 2Gb ram) compiled my website quicker than my desktop (quad core 3ghz with 16Gb ram). Both have SSD disks. Build options all set correctly (the same, core count = parallel builds) yet the laptop runs the site in a few seconds and the dekstop runs the site in about 30 seconds.

一段时间以来,我一直很困惑为什么我的笔记本电脑(双核 2ghz,2Gb ram)比我的台式机(四核 3ghz 和 16Gb ram)编译我的网站更快。两者都有SSD磁盘。构建选项都设置正确(相同,核心数 = 并行构建),但笔记本电脑在几秒钟内运行该站点,而 dekstop 在大约 30 秒内运行该站点。

Found an additional option under the "Property pages" of the site, under the Build setting, laptop was set to "No Build" and desktop set to "Build and Run". Only found it after the site ran on the laptop without checking for a compiler error.

在站点的“属性页面”下找到了一个附加选项,在构建设置下,笔记本电脑设置为“无构建”,台式机设置为“构建并运行”。只有在网站在笔记本电脑上运行后才发现它,而没有检查编译器错误。

Might help someone in the future so thought I would add it to this post

将来可能会帮助某人,所以我想我会把它添加到这篇文章中

回答by Daniel Nguyen

Another Point to Check is under solution Property Page -->Configuration Properties --> configuration: make sure all checkboxes under Build Column is check for the project you need to be re-complied.

另一个要检查的点是在解决方案属性页-->配置属性-->配置下:确保构建列下的所有复选框都选中您需要重新编译的项目。

回答by user2813625

I tried the previous solutions with mixed results. BUT it seems to work for me whenever I go to Build -> Clean Solution

我尝试了以前的解决方案,但结果喜忧参半。但是每当我去 Build -> Clean Solution 时它似乎对我有用

But it's getting annoying having to do that every single time.

但是每次都必须这样做很烦人。

回答by RBT

For me it was happening because of build configuration settings. My visual studio solution has a number of projects which are a mix of C# and C++ projects. Now I realized that for some weird reason, Visual Studio prefers not to build C++ projects by default which is evident by build configuration settings. I noticed it just after adding a new C++ project into the solution. I don't know why VS doesn't follow same approach while adding a new C# project into the solution.

对我来说,这是由于构建配置设置而发生的。我的 Visual Studio 解决方案有许多项目,它们混合了 C# 和 C++ 项目。现在我意识到出于某种奇怪的原因,Visual Studio 不喜欢默认构建 C++ 项目,这在构建配置设置中很明显。在解决方案中添加一个新的 C++ 项目后,我注意到了这一点。我不知道为什么 VS 在向解决方案中添加新的 C# 项目时不遵循相同的方法。

Right click solution file in solution explorer -> Click properties in context menu -> Select Configuration Properties node in left pane -> Select Configuration node. It shows the list of all the projects in the solution. The first project LearnDs is a C++ project. Notice the check box in build column in first row. It is unchecked. This was the reason why Visual Studio 2010 wasn't building my C++ project (on pressing F5) which contained some changes since it was last built successfully.

右键单击解决方案资源管理器中的解决方案文件 -> 单击上下文菜单中的属性 -> 在左窗格中选择配置属性节点 -> 选择配置节点。它显示解决方案中所有项目的列表。第一个项目 LearnDs 是一个 C++ 项目。请注意第一行构建列中的复选框。它是未经检查的。这就是为什么 Visual Studio 2010 没有构建我的 C++ 项目(按 F5)的原因,其中包含自上次成功构建以来的一些更改。

enter image description here

在此处输入图片说明

The moment I checked the corresponding checkbox and saved the build configuration settings for the solution, it worked. Now I see below prompt whenever I press F5 as VS is able to detect that there are some new changes since it was last built. This prompt is because my settings in Tools menu -> Options submenu -> Projects and Solutions node -> Build and Run Node-> "On Run, when projects are out of date" is set to Prompt to build. In case you don't like this prompt then set it to Always build.

当我选中相应的复选框并保存解决方案的构建配置设置时,它起作用了。现在,每当我按 F5 时,我都会看到下面的提示,因为 VS 能够检测到自上次构建以来有一些新的变化。这个提示是因为我在工具菜单 -> 选项子菜单 -> 项目和解决方案节点 -> 构建和运行节点-> “在运行时,当项目过期时”中的设置设置为Prompt to build. 如果您不喜欢此提示,请将其设置为Always build.

enter image description here

在此处输入图片说明

回答by Poovizhi

Tool --> Options --> Project and Solutions.

工具 --> 选项 --> 项目和解决方案。

  1. Set as Always build / Prompt to Build for "On Run, The project is out of date"
  2. Uncheck the check box for "Only build startup projects and dependencies on Run"
  1. 为“运行时,项目已过期”设置为始终构建/提示构建
  2. 取消选中“仅在运行时构建启动项目和依赖项”复选框