不必要的重建项目在Visual Studio中时,单元测试 [英] Unnecessary project rebuilds when unit testing in Visual Studio

查看:158
本文介绍了不必要的重建项目在Visual Studio中时,单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道<一个href=\"http://stackoverflow.com/questions/567939/visual-studio-2008-unnecessary-project-building/775272\">this问题(和答案),但尽管尝试所有建议的选项,我仍然坚持。

I know about this question (and answers), but despite trying all the suggested options I am still stuck.

我有多个项目的解决方案,但对于这种特殊情况下,让我们说,我有我的 ExampleProjectA 和相应的单元测试项目 ExampleProjectATest 。第一个是加入到测试项目的引用 - 不是通过Visual Studio的项目引用但作为一个链接DLL(类似 .. \\路径\\ $(配置)\\ ExampleProjectA.dll) - 这是由于在建立公司的服务器的要求,但问题还存在的时候,我们仍然有 项目引用

I have a solution with multiple projects, but for this particular case let's say I've got my ExampleProjectA and a corresponding unit test project ExampleProjectATest. The first one is added as a reference to the test project - not via Visual Studio's "Project References" but as a link to the DLL (something like "..\Path\$(Config)\ExampleProjectA.dll") - this is due to build server requirements in our company, but the problem also existed when we still had "Project References".


  • 建筑,然后运行一个单一的单元测试正常工作

  • 在一个单元测试只改变一个字母,然后让试运行始终会导致重建 ExampleProjectA ,即使这不应该是必要
  • 设置都在各自的属性(当时只有几个)的 ExampleProjectA 文件从始终复制到是否有更新的复制并没有帮助

  • 检查下工具=&GT的复选框;选项​​=&GT;项目和解决方案= GT;建立一个运行(见下文),也没有任何改变

  • Building and then running a single unit test works fine
  • Changing just a single letter in a unit test and then letting the test run always results in a rebuild of ExampleProjectA, even though this shouldn't be necessary
  • Setting all (there were only a few) files in ExampleProjectA from "Copy always" to "Copy if newer" in their respective properties didn't help
  • Checking the checkbox under Tools => Options => Projects and Solutions => Build an Run (see below) also didn't change anything

要看看是否有任何可用的信息,我改变了构建输出设置诊断。每次重建 ExampleProjectA 的触发,在输出窗口的第一行是

To see if there was any more information available, I changed the build output settings to diagnostic. Each time a rebuild of ExampleProjectA is triggered, the first line in the output windows is

1>项目'ExampleProjectATest'不是最新的。输入文件'C:\\ TFS \\ mysolution-dev的\\ exampleprojectatest \\ MyFolder文件\\ namegeneratortest.cs'被修改输出文件之后,C:\\ TFS \\ mysolution-dev的\\ exampleprojectatest \\ BIN \\发布\\ exampleprojectatest.pdb

写入窗口类名(例如 namegeneratortest.cs )根据我更改的测试文件更改。

The class name written to the window (e.g. namegeneratortest.cs) changes according to which test file I change.

不知道为什么这条消息出现,但下一步是禁用的下下面显示的调试信息项目属性=&GT;构建= GT;高级=&GT;输出=&GT;调试信息=&GT;无

Not sure why this message comes up, but the next step was to disable the debugging information as shown below under Project properties => Build => Advanced => Output => Debug Info => None:

还是一样,没什么改变。

Still the same, nothing's changed.

我想另一件事是检查包含在我的解决方案文件夹中的文件的时间戳(因为是其中一个用户有一个有前途的时间戳的文件的情况下 - 见链接后) - 无济于事

Another thing I tried was to check the timestamps of the files contained in my solution folder (as there was a case where a user had a file with a future timestamp - see linked post) - to no avail.

最后一件事我想是改变在配置管理器构建设置为不同的目标平台 - 有些设置不会让我成功地构建解决方案,其他一些设置做到了,但描述的问题依然存在,所以没有任何变化。

Last thing I tried was to change the build settings in the Configuration Manager to a different target platform - some settings wouldn't let me build the solution successfully, some other settings did, but the problem described persisted, so no change.

的行为类似于同时与Visual Studio的测试运行,并提供ReSharper的一个(不是虽然一样)。

The behaviour is similar (not the same though) with both the Visual Studio Test Runner and the one provided by ReSharper.

Visual Studio的测试运行

项目ExampleProject'不是最新的。输入文件'C:\\ TFS \\ mysolution-dev的\\ exampleprojecta \\查看\\共享\\ someview.cshtml'是输出文件'C:\\ TFS \\ mysolution-dev的\\ exampleprojecta \\ BIN \\ exampleprojecta.pdb'后修改。

ReSharper的测试运行

项目ExampleProjectATest'不是最新的。输入文件'C:\\ TFS \\ mysolution-dev的\\ exampleprojectatest \\ MyFolder文件\\ namegeneratortest.cs'被修改输出文件之后,C:\\ TFS \\ mysolution-dev的\\ exampleprojectatest \\ BIN \\发布\\ exampleprojectatest.pdb

我在使用Visual Studio 2013 premium版采用ReSharper的8.2和最新的更新,我们的解决方案文件中的项目是在C#。

I'm using Visual Studio 2013 Premium Edition with ReSharper 8.2 and the latest updates, the projects in our solution file are in C#.

更新

要澄清 - 在输出窗口中的第一行不表明测试项目必须重建 - 这是好的。下面的几行,但表示还 ExampleProjectA 的重建,这不应该是必要的。在输出窗口后续消息也表明,其他项目(从 ExampleProjectA 引用必须重建。

To clarify - the first line in the output window does show that the test project has to be rebuilt - this is fine. The following lines, however, indicate that also ExampleProjectA has to be rebuilt, which shouldn't be necessary. Subsequent messages to the output window also show that other projects (referenced from ExampleProjectA have to be rebuilt.

更新2

尽管安装Update 4,一切都没有改变。

Despite installing Update 4, nothing has changed.

推荐答案

有关我的情况的解决方案是始终复制从更改配置文件的生成操作为复制,如果新。过了一段时间发现,因为我不得不改变生成输出的详细信息,以获得关于哪些文件导致错误,例如

For my case the solution was to change the build action of a config file from "Copy always" to "Copy if newer". It took a while to find as I had to change the build output details to get the details about which file was causing the error, e.g.

项目XYZ是不是最新的。工程项目C:\\我的\\路径\\ web.config.dev'有'复制到输出目录属性设置为复制总是

从我的经验也可能发生,建立多次在不同的文件名显示,所以请确保您有正确的和/或再次构建,如果问题仍然存在。

From my experience it can also happen that different file names are shown when building multiple times, so make sure you have the right one and / or build again if the problem persists.

也看看<一个href=\"http://stackoverflow.com/questions/2762930/vs2010-always-thinks-project-is-out-of-date-but-nothing-has-changed\">this问题及其答案中找到一些更多的信息。

Also have a look at this question and its answers to find some more information.

这篇关于不必要的重建项目在Visual Studio中时,单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆