Problem with VSTS UnitTesting. Can't provide C ++ DLL

I am using VSTS Unitesting platform. I am trying to test a method that got assembly references which in turn contain a DllImport for a C ++ DLL.

For it to work, I need to copy the C ++ DLLs so that they are in the same directory as the EXE and DLL.

Of course, when I use the same code with Unittest, I need to provide these DLLs as well. I found out that Unittest is using us by using $ (Solution) \ TestResults [WorkSpace] [DateTime] \ Out as the working directory.

If I manually copied the C ++ libraries into that directory, the unit test works like a charm.

The problem is that every time Unitest is running a new directory is created.

Has anyone come across this? do you have a solution?

Thanks, Ariel

0


source to share


2 answers


As Steve D mentions, deployment items are the answer. You can either put them in a class, test the method using an attribute, or use the test run configuration to add them so that when you run any tests from this solution, they are deployed.

Another option is to make sure they are in the path somewhere in order to apply the standard Windows DLL search rules so the runtime can find them.



Why is this a problem? because they have little metadata from project to Native DLL - we don't know how to pick it up. The only option would be to dive of all types into deployed managed DLLs looking for the DllImport attribute. This, however, will fail if you execute explicit DLLLoads in managed code.

0


source


You can try using the [DeploymentItem] attribute. It allows you to specify a relative path from a solution file that will be copied to the test output directory.



0


source







All Articles