locked
Build, Deploy, Test Workflow - Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITesting RRS feed

  • Question

  • Hi,

    We've spent the last few days attempting to set up a new Lab environment so that we can use the Build, Deploy, Test workflow. For the most part we have been successful, however, we are having issues running the tests on the Build Agent.

    After the deployment succeeds successfully, the test returns the following error:

    ""Error adding test case [27005] to test run: Unable to load the test container '\\<BUILD_FOLDER>\<PROJECT>.dll' or one of its dependencies.
    Error details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITesting, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."

    Our configuration is TFS Server, Test Controller, Test Agent all on different machines.


    On reading another thread: http://social.msdn.microsoft.com/Forums/en-US/c6c84b5f-52e7-48f6-a478-dc2af6a432d3/tfs-problems-with-automated-testing?forum=tfsadmin

    It sounded like we may need to install Visual Studio on the Test Controller as well but this hasnt helped.

    The test solution has references to: 

    Microsoft.VisualStudio.QualityTools.CodedUiTestFramework

    Microsoft.VisualStudio.QualityTools.UnitTestFramework

    Microsoft.VisualStudio.TestTools.UITest.Common

    Microsoft.VisualStudio.TestTools.UITest.Extension

    Microsoft.VisualStudio.TestTools.UITesting

    I tried changing the setting to Copy Local = TRUE but only the UnitTestFramework DLL was copied to the drop.

    Where are these DLLs supposed to be located? Test Controller? Test Agent? Both? Somewhere else? What should be installed to achieve this?

    Having enabled verbose logging on the Controller, it appears to report the same error.

    On another note, The test run is also looking in my root drop folder for my project DLL - where is this setting as this is not ideal. 

    Thanks

    Craig

    Tuesday, January 14, 2014 5:11 AM

Answers

  • Hi Cheddzz,

    According to the error message you got:"Error details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITesting, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified", it seems that you reference a VS2012 version assembly. However, C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.TestTools.UITesting assembly has 12.0.0.0 version. That is the reason why you need to copy the assembly from the C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies folder.

    And for the new error you got: "Unit Test Adapter threw exception: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information", please provide me the detailed error message of it.

    Thanks.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 17, 2014 3:14 AM
  • We eventually tracked this problem down to the fact that the project was compiled using a TFS 2012 build agent.

    Until we can upgrade to a 2013 build agent, a workaround was to:

    • Ensure VS 2013 is installed on the TFS 2012 build agent machine
    • Comment out the conditional <Reference> elements in the .csproj
    • hard-code  <VisualStudioVersion>12.0</VisualStudioVersion>
    • hard-code the References (copied from the 2013 Microsoft.TestTools.targets)
      <ItemGroup>
        <Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <Private>False</Private>
        </Reference>
        <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <Private>False</Private>
        </Reference>
        <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <Private>False</Private>
        </Reference>
        <Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <Private>False</Private>
        </Reference>
        <Reference Include="UiaComWrapper, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <Private>False</Private>
        </Reference>
      </ItemGroup>

    This allows the build agent to compile the test project and it is then looking for the 12.0.0.0 assemblies.

    -david

    Wednesday, January 22, 2014 4:27 AM

All replies

  • Hi Cheddzz,

    Thanks for your post!

    As you said “It sounded like we may need to install Visual Studio on the Test Controller as well but this hasnt helped”. I would like to know did the VS has been installed in the Test Controller machine.

    In my opinion, many tests should dependence some dll files that can be get by install the VS. So I suggest that you should install the VS and try again.

    Based on my test, the dll won’t copied to the drop folder or bin folder if I set Copy Local to true.

    On the other hand, the exception thrown when enumerating assembly (Get it from test controller log). So in my opinion, these dll files should be in the Test Controller’s machine.

    Thanks

    Best Regards  


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 14, 2014 8:52 AM
  • Hi Starain,

    Thanks for your reply,

    I have reinstalled VS 2013 again and still have the same result:

    If I run the build definition without the Test Project DLL in the drop, i get the following error: 

    Error adding test case [27005] to test run: File does not exist. Could not find file \\<BUILD_FOLDER>\<PROJECT>.dll' 

    Once the DLL is there, the error changes to:

    Error adding test case [27005] to test run: Unable to load the test container '\\<BUILD_FOLDER>\<PROJECT>.dll' or one of its dependencies. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITesting, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

    If I browse to the C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies directory and manually copy the Microsoft.VisualStudio.TestTools.UITesting DLL and drop it into the root of the drop folder with the project DLL then I get this error:

    "Error adding test case [27005] to test run: Unable to load the test container '\\<BUILD_FOLDER>\<PROJECT>.dll'' or one of its dependencies. Error details: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITesting, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

    I am unsure where to go from here!

    Thanks

    Wednesday, January 15, 2014 1:21 AM
  • Hi Cheddzz,

    Could you run that Coded UI test in the test controller and test agent machine in the VS?

    On the other hand, please check whether the “C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.TestTools.UITesting.dll” file is exist in the test controller and test agent machine.

    Thanks

    Best Regards  


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, January 15, 2014 8:19 AM
  • There were 5 DLLs that were in the C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies\ folder but for some reason it is looking for the V11.0 files.

    By manually copying them from C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies\ and putting them in the root folder with the project DLL, we get past that error but end up with another one:

    Unit Test Adapter threw exception: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
    Thursday, January 16, 2014 11:44 PM
  • Hi Cheddzz,

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Thanks

    Best Regards  


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 17, 2014 1:46 AM
  • Hi Cheddzz,

    According to the error message you got:"Error details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITesting, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified", it seems that you reference a VS2012 version assembly. However, C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.TestTools.UITesting assembly has 12.0.0.0 version. That is the reason why you need to copy the assembly from the C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies folder.

    And for the new error you got: "Unit Test Adapter threw exception: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information", please provide me the detailed error message of it.

    Thanks.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 17, 2014 3:14 AM
  • We eventually tracked this problem down to the fact that the project was compiled using a TFS 2012 build agent.

    Until we can upgrade to a 2013 build agent, a workaround was to:

    • Ensure VS 2013 is installed on the TFS 2012 build agent machine
    • Comment out the conditional <Reference> elements in the .csproj
    • hard-code  <VisualStudioVersion>12.0</VisualStudioVersion>
    • hard-code the References (copied from the 2013 Microsoft.TestTools.targets)
      <ItemGroup>
        <Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <Private>False</Private>
        </Reference>
        <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <Private>False</Private>
        </Reference>
        <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <Private>False</Private>
        </Reference>
        <Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <Private>False</Private>
        </Reference>
        <Reference Include="UiaComWrapper, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <Private>False</Private>
        </Reference>
      </ItemGroup>

    This allows the build agent to compile the test project and it is then looking for the 12.0.0.0 assemblies.

    -david

    Wednesday, January 22, 2014 4:27 AM
  • We updated to the TFS 2013 build agents and saw the exact same behavior. Turns out it has nothing to do with the version of the build agent.  It is the version of the build template you are using, and which version of the MSBuild task it is invoking.

    Your solution does work.  However, I found a less-invasive solution here that worked for us: 
    http://stackoverflow.com/a/22556702/1001100

    There's really two ways to fix it with this approach:

    1. Do what the StackOverflow post suggests:  In the build definition, add /p:VisualStudioVersion=12.0 as a command-line argument to MSBuild.  You can even test it first by supplying the parameter when queuing the build.
    2. Do what this StackOverflow post suggests: Modify the build template itself to always supply 12.0 as the build tools version.  This might be better for you, if you have a lot of build definitions.


    Friday, September 19, 2014 8:35 PM