Build/Test Issues

"Directory Not Found" when testing an assembly that relies on content files

Started by Tim Long on 4,193 views

I'm having a problem running tests against a class library that relies on content files that are expected to be in the same location as the class library assembly.

I have the content files (plain text) configured as "Content" and "Copy Always" to the output directory. The files get copied to a subdirectory in the class library's bin/Debug folder during build.

However when NCrunch runs my tests, the class library throws:

System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Tim\AppData\Local\NCrunch\2532\9\TA.ObjectOrientedAstronomy.Specifications\bin\Debug\Vsop87_data\VSOP87B.ear'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)


Sure enough, the entire subdirectory is missing from the workspace (both the bin/Debug and obj/Debug).

Isn't it reasonable to expect content files to be copied to the test workspace?

Note: I've considered making the files embedded resources, but that's ruled out because the data files must be end-user replaceable.

Best regards,
Tim Long

Wait! Solved it...

The class library was referencing the content as ".\subdirectory\filename" which was a bad assumption. I've replaced that with a location based on Assembly.GetExecutingAssembly().Location and that seems to be working now. False alarm, sorry.

--Tim

Post a reply

Log in to reply.