none
Visual Studio Project references do not deploy to unit test directory RRS feed

  • Question

  • When I run all tests in the solution, my unit tests pass. When I select a single solution, the unit tests for this solution fail.

    The error message I get is related to missing DLLs in the directory in which the test are run (under TestResult directory).

    I have the following project reference structure:

    TestProject -> TestedProject -> TestedProjectDepencies as well as other dependencies for the TestProject directly.

    The test fails because the references I added for TestProject are not copied into the directory where the tests are run. Running the tests create a Deploy_xxx directory under the TestResults directory of the solution. I assume that when I run all unit tests in the solution, other test project are able to copy the referenced DLL. If I compare the 2 directories underneath the TestResults directory (when running a single test, and when running multiple) I can clearly see that running all tests copies a lot more DLLs and that some DLL specifically referenced from the test project are not copied.

    • The "Copy Local" setting is set on all references.
    • The references are correctly copied to the OuputDirectory ( bin\Debug)
    • There is no error visible in the Output window
    • If I call vstest.console  directly on the project assembly, I have the same behavior: needed DLLs are not copied.

    What could prevent the DLLs dependencies from being detected?

    Here is a copy of the log from vstest.console:

    TpTrace Information: 0 : 38872, 9, 2019/08/06, 16:07:21.469, 220633542015, vstest.console, AssemblyDependencyFinder.GetDependentAssemblies: start.
    TpTrace Information: 0 : 38872, 9, 2019/08/06, 16:07:21.469, 220633543305, vstest.console, AssemblyDependencyFinder.GetDependentAssemblies: Using config file: 'C:\TFS\Dev\Source\DotNet\SITA.AIRCOMServer.Mapping.Layers.Test\bin\Debug\SITA.AIRCOMServer.Mapping.Layers.Test.dll.config'.
    TpTrace Information: 0 : 38872, 9, 2019/08/06, 16:07:21.470, 220633547801, vstest.console, AssemblyDependencyFinder.GetDependentAssemblies: Created AppDomain.
    TpTrace Information: 0 : 38872, 9, 2019/08/06, 16:07:21.488, 220633729008, vstest.console, AssemblyDependencyFinder.GetDependentAssemblies: loaded the worker.
    TpTrace Information: 0 : 38872, 9, 2019/08/06, 16:07:21.558, 220634430908, vstest.console, AssemblyDependencyFinder.GetDependentAssemblies: unloading AppDomain...
    TpTrace Information: 0 : 38872, 9, 2019/08/06, 16:07:21.562, 220634471602, vstest.console, AssemblyDependencyFinder.GetDependentAssemblies: unloading AppDomain succeeded.

    (this part edited for security)

    TpTrace Information: 0 : 38872, 9, 2019/08/06, 16:07:21.562, 220634472913, vstest.console, DeploymentManager: Source:...Layers.Test.dll has following references
    TpTrace Information: 0 : 38872, 9, 2019/08/06, 16:07:21.562, 220634473491, vstest.console, DeploymentManager: Reference:....Layers.Test\bin\Debug\....Layers.dll 
    TpTrace Information: 0 : 38872, 9, 2019/08/06, 16:07:21.562, 220634473975, vstest.console, DeploymentManager: Reference:....Layers.Test\bin\Debug\Microsoft.SqlServer.Types.dll 

    (...)

    But it does not detect all the references specified in the project.

    Tuesday, August 6, 2019 8:19 PM

All replies

  • Hi Vlcent Hubert,

    Welcome to MSDN forum.

    >>When I run all tests in the solution, my unit tests pass. When I select a single solution, the unit tests for this solution fail.

    Did you have one solution or multiple solutions with unit tests? Is the single solution a test project?

    Please try to refer to the tested project assembly other than project and copy the dlls which the project needs to corresponding directory manually.

    Any feedback will be expected.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Wednesday, August 7, 2019 3:31 AM
  • Hi Dylan.

    >>When I run all tests in the solution, my unit tests pass. When I select a single solution, the unit tests for this solution fail.

    >Did you have one solution or multiple solutions with unit tests? Is the single solution a test project?

    (My error, let me rephrase) I have one solution with multiple projects in it. If I run all tests in the solution, they all pass. If I run all tests in a specific project within that solution. Some test fails complaining about missing DLLs.

    I run the tests wihin VS 2017, either clicking on the "Run All" at the top (tests pass). I run the tests within VS, right clicking on a test project in the test explorer (the tests fail). I run the tests using the vstest.console application, specifying the assembly to test. (the tests fail)

    >>Please try to refer to the tested project assembly other than project and copy the dlls which the project needs to corresponding directory manually.

    Not sure I understand what I am supposed to do. The DLLs are automatically copied by either VS and vstest.console just before running the test, into the TestResult\Vincent_Hubert_...\Out directory. How am I supposed to copy the DLLs into that directory?
    Wednesday, August 7, 2019 9:06 PM
  • Hi Vlncent Hubert,

    Thank you for reply.

    Please try to refer to the tested project assembly and testedProjectDepencies as well as other dependencies for your test project directory. It is like:

    TestProject -> TestedProject assembly and TestedProjectDepencies as well as other dependencies.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, August 8, 2019 7:17 AM
  • Dylan

    Still not sure I understand your suggestion.

    Assuming

    • TP: Test Project
    • A  : Assembly under test
    • AD: A dependencies.

    I am currently setup like this (-> meaning is a reference in the project)

    TP -> A

    A -> AD

    TP-> AD

    After looking at the trace, it looks like vstest.console does not use the project references, but the assembly dependencies. Which mean that if (A) dynamically load some assembly, it need to be manually deployed even if the reference is set correctly in the project. Can you confirm?

    Thursday, August 8, 2019 3:31 PM
  • Hi Vlncent Hubert,

    Thank you for details.

    After my experiments, I could not reproduce this issue. And did you have a runsettings file for your test projects? If so, please check if the settings file is set to call and collect related data from references.

    And if possible, could you please share a simple sample to help us analysis this issue?

    Look forward to your reply.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, August 9, 2019 6:49 AM
  • Hi Dylan, 

    Providing a scaled down sample would probably be a long endeavour. I will try to do it over the following weeks.

    V

    Friday, August 9, 2019 1:28 PM