Monday, 20 December 2010

Automatic Update Of Moles References To Other Solution Projects

The situation: I have a solution with several projects in it. One of them is UnitTest project, that uses Moles for mocking. And it has referenses to other projecs in solution as well as to their moled dlls. Every time I change code in my projects and rebuild them, the UnitTest project loses the references to moled dlls, as they allready have other versions. I see that Moles builds new versions of projects' dlls, but it does not update references. Why?

RTFM, Juri.

From the Microsoft Moles Reference Manual (page 12)

The Moles framework for Visual Studio monitors build events and automatically forces the regeneration of stub types for projects that have been updated. For efficiency reasons, this automatic update only works for .moles files that are in the top level folder of the project, to avoid walking large nested project structures. This automatic update creates a smooth experience when writing code in a test-driven development style.

So the automatic update of references works only for .moles files that are in the same folder with the project file. But I have moved all the .moles files into separate folder.

Now that I moved all the .moles files back, it is working.