12

The solution I'm working on contains 400+ projects. The issue is not reproducible but very annoying. (Windows 8.1, Visual Studio 2015 Update 2 and 3)

Basically, some project dependencies are not taken into account when calculating build order. The process stops with an error: the referred dll cannot be found. It occurs every now and then, usually with a different project 'missing'. Many of the times nothing is wrong and it just works. Could not find any pattern.

If I build the 'missing' project by hand and then build the solution, everything is fine, or an other project goes 'missing'.

It seems, as if VS had lost track of project dependencies, although every reference is there, as seen is VS and in the csproj files.

See the screenshot: Solution build has stopped, because a dll is missing. The project that produces the dll is referenced correctly (see solution explorer), but is not visible in the Project Dependencies dialog. My guess is that because of that missing dependency, the build order gets confused and - based on some randomness due to parallel compilation - in some cases the dependent project gets built too late.

dependency not recognized properly

Note: yes, I could just check that check box but as I said, this issue occurs randomly and with random projects. And yes, I can work around the problem by manually building the affected projects beforehand. I am looking for a solution to the root problem.

Any hints and comments are welcome.

6
  • I've faced issues at the time of adding these references; it needs to be explicitly saved. (I do a File->save all to avoid similar errors). Closing and starting VS again has also helped me every now and then.
    – Ramya Rao
    Commented Nov 16, 2016 at 19:51
  • Based on your description, I create a demo with 3 project (1 main project, 2 class library project). The main project add reference from 2 class library project, then I open Project Dependencies, I could not uncheck the class library. it will pop up a windows with 'this dependency was added by project system and can not be removed', Could you please provide a method about how to reproduce your issue on our side. Commented Nov 17, 2016 at 2:00
  • @Cole: No way to reproduce it. Every now and then it just occurs, with a random project. And yes, the checkbox should be checked and gray, but sometimes it is not. This is the symptom and I am looking for the root cause or some solution.
    – Dercsár
    Commented Nov 17, 2016 at 10:48
  • @Ramya: Changes in .csproj are not saved automatically so you need to save by hand. You can use Ctrl-Shift-S to save everything, including csproj. That's a different issue.
    – Dercsár
    Commented Nov 17, 2016 at 10:52
  • My solution has just 60-something projects and it appears to happen mostly after SVN-switching to different branches. If it happens, then it's on the first build run after the switching. Workaround is closing and reopening the solution once or twice, it usually works then. Seen on VS 2015.3, but also on VS 2019. Commented Mar 5, 2020 at 15:07

2 Answers 2

1

Sometimes I have noticed that using an import helper (such as ReSharper) can cause a dependent project to link to the output of another dependent project instead of the dependency source.

This is to say that if you were to create a project - let's call it 'ProjectA' - and link it to library 'MyLib' then create 'ProjectB' and allow ReSharper to auto-resolve dependencies to link to 'MyLib' you might find that ReSharper will actually link to the .\ProjectA\Bin\MyLib.dll file rather than the .\Libraries\MyLib\MyLib.dll file.

When you rebuild your solution the following may occur: * ProjectB happens to build first/faster (because, perhaps, ProjectA has many changes but ProjectB only has few code changes). * ProjectB then attempts to link to the MyLib.dll located in ProjectA's \bin folder and can't find it. * ProjectA completes building and copies it's dependency - MyLib.dll to it's \bin folder. * ProjectB is not rebuilt manually by you and now has no problems locating \ProjectA\bin\MyLib.dll.

So, in summary, check the exact source location of dependencies in your project. I'd hazard a guess that with 400+ projects some includes have become crosswired.
Good luck!

2
  • 1
    Next time you see this behavior could you please check the Project Dependencies dialog? Note, that if the issue was from the csproj file being 'crosswired', it would be a permanent issue and this is not the case. Thanks for the tip anyway, will check if R# has anything to do with it.
    – Dercsár
    Commented Nov 28, 2016 at 13:06
  • The intermittent behavior may be caused by compilation-races or by the IDE deciding that you DO need to rebuild project X. (For me, VS2012 for some reason would occasionally go through periods of deciding to rebuild a library project every time code in the main project changed).
    – Monza
    Commented Nov 28, 2016 at 22:18
0

In my case I had to delete all errors from .csproj of target project. I deleted elements that contained Error in a name, saved the change, reloaded the project and rebuilded it. This solution was discovered on Visual Studio 2019 16.6.1.

Not the answer you're looking for? Browse other questions tagged or ask your own question.