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());

3 thoughts on “MsTest Original File Location

  1. I’m now not positive the place you’re getting your info, however great
    topic. I must spend some time learning much more or working out more.
    Thank you for wonderful information I was in search of this information for my mission.

  2. So the scope of this project was more than the previous research in cities such as Florence and Rome, where only the presence and movements of tourists was mapped.

  3. Thanks, this is exactly what I was looking for. +1 to you for this solution, -10000 to Microsoft for not providing such a property on TestContext in the first place.

Leave a Reply

Your email address will not be published. Required fields are marked *