How do I add a VSTO project as a reference to a unit testing project?
unit-testing, vsto
Solution
I can offer an answer to the last part of your question about avoiding the issue.
One way to get around this is to separate the code that doesn't explicitly reference VSTO libraries into another project, and then test that - I understand that this will likely involve an effort to actually have code that doesn't reference VSTO.
But this way, the code you are testing is code that can be tested without referencing VSTO and the VSTO-specific code would probably be tested via integration tests (manually or via an API like White - where White doesn't need to reference VSTO because it merely runs executable code that uses VSTO)
While this may mean some significant redesign - you may need to create wrapper-classes, for example - and it may not be feasible for you right now, I believe that this is generally seen as a good practice (it's a kind of separation of concerns) because it would make it easier to manage code and often helps isolate certain bugs from VSTO complications.
Problem
In order not to pollute my projects with unit tests, I like to create a separate project for my unit tests; I add a reference to the project under test in the unit tests project. However, this isn't working that well with my VSTO excel add-in projects: when I create a separate unit test project and go to Add Reference > Projects, there is no project to pick. What I have done so far is Add Reference > Browse, and pick the add-in dll from the debug folder. I have also run into issues from time to time with this, with the reference suddenly not working, requiring to remove/re-add the dll reference. Can anybody explain why a VSTO project doesn't show up as a regular project? And is there a better way to go about it than what I am doing presently?