MSTest set working directory


I've got a problem with some C# unit tests that work find in Visual Studio, but fail in TeamCity.

The problem is because a common part to each test runs something like:

File.Copy(@"..\..\..\Build\data\Input\test1.out", executionPathUri.LocalPath + \\test1.out, true);

The "Build" directory is at the same level as the project directories.

When the tests run in Visual Studio, the working directory is "MyProj.UnitTests\bin\Debug", so "..\..\..\Build" is valid.

When they run in TeamCity, the working directory is "D:\TeamCity\BuildAgent1\work\dbf2c5274c7acb97", so "..\..\..\Build" is invalid (as it's above the checkout directory).

Is there a way around this?  The MSTest build runner seems to be one of the few that does not allow the setting of an alternate working directory... why?

Comment actions Permalink

I would like to explain why configurable working directory is important in TeamCity.


Imagine I have some older project which is hard to modify (too big, authors are already gone, etc..) ant this project is design in a way that all MSTest deployment items contains path relative to repository subdirectory.

If I want to add this project to TeamCity, I cannot use MSTest runner, because all deplyoment items will be copied to wrong place unless I set up this subdirectory as working directory of MSTest. OK, I can handle it with calling MSTest from commandline and setup working directory of command line.

But if I want to use dotCover, thinks ass well, thinks started to be more complicated. I need to solve all command lines of mstest dotcover, report generation etc..

I need to do everything in command line which is annoying if there is such awesome UI in TeamCity only because of I cannot setup working directory for MSTest.



Please sign in to leave a comment.