none
Building coded ui test project fails when “Perform runtime contract checking” is set to “full”

    Question

  • I have a simple Test project where a CodedUITestMethod is created. The test method simply clicks the Windows Start button in the taskbar. The method is generated by the Coded UI Test Builder tool from Visual Studio 2010 Ultimate.

    Then, I go to project's Properties page, Code Contracts tab. Check the Perform Runtime Contract Checking check box. Change the value of Contract Reference Assembly combo box to "Build".

    Now I hit F6 to build the project and receive the 2 errors: Reading assembly 'Microsoft.VisualStudio.TestTools.UITesting' resulted in errors.

    C:\Program Files (x86)\Microsoft\Contracts\MsBuild\v4.0\Microsoft.CodeContracts.targets(240,5): error MSB3073: The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite" "@CodedUITest_Contract2ccrewrite.rsp"" exited with code -1.

    I have uploaded my project zip file to my codeplex project

    Could someone download the project and see if they can reproduce the compile error? Thanks.


    Jacob
    Tuesday, July 19, 2011 6:08 PM

Answers

  • Yes, I have the same experience. So it is not just your setup.  As the error indicates, we must look at the output window for further info.
    ------ Build started: Project: CodedUITest_Contract2, Configuration: Debug Any CPU ------
     elapsed time: 136.0078ms
     Reading assembly 'Microsoft.VisualStudio.TestTools.UITesting' from 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\
    Microsoft.VisualStudio.TestTools.UITesting.dll' resulted in errors. Assembly reference not resolved: Microsoft.VisualStudio.TestTools.UITest.Playback, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Could not resolve type reference: [Microsoft.VisualStudio.TestTools.UITest.Playback]Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement. ccrewrite : error : Rewrite aborted due to metadata errors. Check output window elapsed time: 2559.1463ms C:\Program Files (x86)\Microsoft\Contracts\MsBuild\v4.0\Microsoft.CodeContracts.targets(240,5): error MSB3073: The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite" "@CodedUITest_Contract2ccrewrite.rsp"" exited with code -1. ========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
    I then used ildasm.exe to open up the Microsoft.VisualStudio.TestTools.UITesting.dll indicated above. Here is a fragment from the output
    .assembly extern Microsoft.VisualStudio.TestTools.UITest.Common
    {
     .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )             // .?_....:
     .ver 10:0:0:0
    }
    .assembly extern System.Drawing
    {
     .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )             // .?_....:
     .ver 4:0:0:0
    }
    .assembly extern Microsoft.VisualStudio.TestTools.UITest.Playback
    {
     .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )             // .?_....:
     .ver 10:0:0:0
    }

     You can see Microsoft.VisualStudio.TestTools.UITesting.dll' references Microsoft.VisualStudio.TestTools.UITest.Playback, but that dll is not referenced.
    Then I went hunting on my hard drive, and found it at  
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies
     I added that reference, and could rebuild without problems.
    I don't really understand some of the nuances here, but you can see now, with hindsight at the error message is leading us to the solution. What I don't know is what an private assembly is. I'll let you figure that out and tell me ;)

    Best Regards, David K Allen http://codecontracts.info Minneapolis, Minnesota, USA
    Friday, July 22, 2011 1:17 AM

All replies

  • Yes, I have the same experience. So it is not just your setup.  As the error indicates, we must look at the output window for further info.
    ------ Build started: Project: CodedUITest_Contract2, Configuration: Debug Any CPU ------
     elapsed time: 136.0078ms
     Reading assembly 'Microsoft.VisualStudio.TestTools.UITesting' from 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\
    Microsoft.VisualStudio.TestTools.UITesting.dll' resulted in errors. Assembly reference not resolved: Microsoft.VisualStudio.TestTools.UITest.Playback, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Could not resolve type reference: [Microsoft.VisualStudio.TestTools.UITest.Playback]Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement. ccrewrite : error : Rewrite aborted due to metadata errors. Check output window elapsed time: 2559.1463ms C:\Program Files (x86)\Microsoft\Contracts\MsBuild\v4.0\Microsoft.CodeContracts.targets(240,5): error MSB3073: The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite" "@CodedUITest_Contract2ccrewrite.rsp"" exited with code -1. ========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
    I then used ildasm.exe to open up the Microsoft.VisualStudio.TestTools.UITesting.dll indicated above. Here is a fragment from the output
    .assembly extern Microsoft.VisualStudio.TestTools.UITest.Common
    {
     .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )             // .?_....:
     .ver 10:0:0:0
    }
    .assembly extern System.Drawing
    {
     .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )             // .?_....:
     .ver 4:0:0:0
    }
    .assembly extern Microsoft.VisualStudio.TestTools.UITest.Playback
    {
     .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )             // .?_....:
     .ver 10:0:0:0
    }

     You can see Microsoft.VisualStudio.TestTools.UITesting.dll' references Microsoft.VisualStudio.TestTools.UITest.Playback, but that dll is not referenced.
    Then I went hunting on my hard drive, and found it at  
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies
     I added that reference, and could rebuild without problems.
    I don't really understand some of the nuances here, but you can see now, with hindsight at the error message is leading us to the solution. What I don't know is what an private assembly is. I'll let you figure that out and tell me ;)

    Best Regards, David K Allen http://codecontracts.info Minneapolis, Minnesota, USA
    Friday, July 22, 2011 1:17 AM
  • It works! Thanks for the answer and a detailed clear guide. 


    Jacob
    Friday, July 22, 2011 1:40 AM