Struggling for Competence

MsTest Original File Location

One of the "features" with MsTest is that it copies the build outputs to a deployment directory before running the tests. This causes a problem in the unusual situation where your test needs to access the original source code tree - it's hard to work out where that code is in a reliable fashion.

After a lot of googling I finallly found a work around to this problem posted by Mihai Danila. It relies on the presence of debug information for the unit test assembly.


string theFolderWhereThisSourceFileIs = Path.GetDirectoryName(new System.Diagnostics.StackFrame(true).GetFileName());