19

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

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".

  • 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 Visual Studio 2013 setting

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>Project 'ExampleProjectATest' is not up to date. Input file 'c:\tfs\mysolution-dev\exampleprojectatest\myfolder\namegeneratortest.cs' is modified after output file 'C:\tfs\mysolution-dev\exampleprojectatest\bin\Release\exampleprojectatest.pdb'.

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

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:

Advanced Build Settings

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.

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

Visual Studio Test Runner

Project 'ExampleProject' is not up to date. Input file 'C:\tfs\mysolution-dev\exampleprojecta\Views\Shared\someview.cshtml' is modified after output file 'C:\tfs\mysolution-dev\exampleprojecta\bin\exampleprojecta.pdb'.

ReSharper Test Runner

Project 'ExampleProjectATest' is not up to date. Input file 'c:\tfs\mysolution-dev\exampleprojectatest\myfolder\namegeneratortest.cs' is modified after output file 'C:\tfs\mysolution-dev\exampleprojectatest\bin\Release\exampleprojectatest.pdb'.

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#.

Update

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.

Update 2

Despite installing Update 4, nothing has changed.

Community
  • 1
  • 1
Gorgsenegger
  • 7,356
  • 4
  • 51
  • 89
  • The error about `ExampleProjectATest\SomeClassTest.cs` being too old sounds... interesting. Can you provide some additional information on that (e.g., the actual output from the build surrounding that message)? – Lilshieste Apr 14 '14 at 18:04
  • @Lilshieste I will provide the requested information, but it won't be before Wednesday as I'm out of office now. – Gorgsenegger Apr 14 '14 at 18:57
  • All the diagnostic messages you got from msbuild indicate that everything is entirely normal. – Hans Passant Apr 16 '14 at 15:36
  • @HansPassant Please explain why `ExampleProjectA` has to be rebuilt when I change a test in `ExampleProjectATest` - why is this necessary? If I used a separate project for tests and referenced the DLL, a rebuild would not be possible (from the within the test project) - I could still add / modify tests and would only have to build the other project if that changed, wouldn't I? Sorry if I'm missing something. – Gorgsenegger Apr 16 '14 at 19:03
  • The ReSharper message you added to your question makes sense, right? (Assuming `namegeneratortest.cs` is the file you made the arbitrary change to.) What about that Visual Studio Test Runner message? Does it always call out `someview.cshtml`? – Lilshieste Apr 16 '14 at 19:53
  • Did you ever find an answer? I seem to be hitting the same issue. I have a Web Site project that is always getting re-built, and it is a huge bottleneck for testing... (I know, I know, convert it to a Web application, and we have, but older releases aren't regression tested for this change and so a lot of older code doesn't have this benefit yet.) – John Zabroski Sep 04 '14 at 04:16
  • @JohnZabroski: No, sorry, still having the same issues unfortunately. – Gorgsenegger Sep 04 '14 at 18:49
  • I found a solution last night. Will post it as an answer below. – John Zabroski Sep 04 '14 at 20:22
  • I am on VS 2013 update 4. I have a related issue where it seems like if `FooTests` depends on `Foo` and `Bar`, and `Bar` also depends on `Foo`, then when `Foo` changes and I want to run `FooTests`, `Bar` gets rebuilt even though the only thing that changes is replacing `Foo.dll`. – wrschneider Nov 03 '15 at 20:17

3 Answers3

14

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.

Project 'xyz' is not up to date. Project item 'c:\my\path\web.config.dev' has 'Copy to Output Directory' attribute set to 'Copy always'.

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.

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

Community
  • 1
  • 1
Gorgsenegger
  • 7,356
  • 4
  • 51
  • 89
  • 2
    I am on Visual Studio 2013 Update 4. This answer cut down *some* of the unnecessary project rebuilds but there still appear to be a few more. – wrschneider Nov 03 '15 at 20:11
  • 1
    Fantastic! We had a project containing nothing but resource files that were "copy always". Since everything depended on this project... everything was always getting built. – Paul Suart Feb 02 '17 at 16:03
1

I have worked around this problem by deleting the .pdb file in the \obj folder. It seems that visual studio is checking file modification time to decide if it should build or not the project (in your case ExampleProjectA) and the .cshtml is newer than the pdb. But when launching the build, project changes in .cshtml files are not triggering the .pdb rebuild, so the problem remains.

By deleting the .pdb in \obj folder (not in \bin as the file there is copied from \obj and would keep the old modification time) the modification time for the .pdb is newer than the .cshtml and the VS doesn't need to build the project before running the tests. Of course this only works until the next time you modify a .cshtml file, that's why I qualify it as just a workaround.

Jorge Y.
  • 1,123
  • 1
  • 9
  • 16
0

Check what version of Visual Studio 2013 you are using. Update 1 has a pretty big issue where it rebuilds everything. See: https://connect.microsoft.com/VisualStudio/feedback/details/811112/unnecessary-solution-rebuild-on-each-test-run

Upgrading to Update 3 did the trick!

I'm not sure if Resharper could affect things as well. I suggest temporarily uninstalling it.

John Zabroski
  • 2,212
  • 2
  • 28
  • 54
  • Thanks, I'll try out Update 3 and see whether things have improved. – Gorgsenegger Sep 05 '14 at 10:11
  • Sorry for the delayed reply, busy busy busy... Unfrotunately the update didn't improve anyhting, changing something in ExampleA also leads to a rebuild of ExampleATest. – Gorgsenegger Oct 10 '14 at 18:08