locked
Fake Assembly not generated RRS feed

  • Question

  • Hi all,

    Could you please help with that?

    I have some builds on TFS, xaml builds, and since I migrate from MSBuild14 to MSBuild15, with migration from VS2015 to VS2017, one of that builds, that has united tests with fake assemblies, stop working, allways return "The type or namespace name 'Fakes' does not exist in the namespace 'XXXXX' (are you missing an assembly reference?)"

    Could you please help to fix that?

    The template we are using, is targeting ToolPath="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin" ToolPlatform="[MSBuildPlatform]"

    By deafult is using MSBuild15 in this case.

    Adicional Information:

    If I build from MSBuild in commandline, this fails with above error.

    If I build on VisualStudio, it generates de fakes and succeeded

    Thank you



    • Edited by HL_Brg Friday, June 30, 2017 4:59 PM new tests done
    Friday, June 30, 2017 3:07 PM

Answers

  • Hi all,

    It's closed, the build it's already done. It pass for 3 steps:

    ### 1 ###

    In csProj, it was necessary to add a Fake: <Fakes Include="Fakes\XXX.fakes" />

    ### 2 ###

    Addictional, we had injected in csproj something like:

    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

    .....

      <Choose>
        <When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
          <ItemGroup>
            <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
          </ItemGroup>
        </When>
        <Otherwise>
          <ItemGroup>
            <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
          </ItemGroup>
        </Otherwise>
      </Choose>

    Resolution:

    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>

    ### 3 ###

    As mentioned by Khang Yeen

    Copy Microsoft.QualityTools.Testing.Fakes.dll file:

    • From Source: c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\
    • To Target: GAC / %windir%\Microsoft.NET\assembly

    Tank you all

    • Marked as answer by HL_Brg Thursday, July 6, 2017 10:56 AM
    Thursday, July 6, 2017 10:52 AM

All replies

  • Hi HL_Brg,

    Thank you for posting here.

    Could you please provide detailed steps about how you fake the assemblies for us to reproduce your issue. In addition, please share the whole build log here and give a screenshot of how you set in the build definition.

    Best regards


    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, July 5, 2017 9:42 AM
    Moderator
  • Hi Tingting,

    On MSBuild I request build with below command:

    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" .\Api.Tests\Api.Tests.csproj /v:diag /p:Configuration=Release

    And Fake was not generated.

    On VS, I build the solution and fakes was generated

    -------------------------------------------------------------------

    LOG Resume

    -------------------------------------------------------------------

    "C:\-----\Api.Tests\Api.Tests.csproj" (default target) (1) ->

    (ResolveAssemblyReferences target) -> 
      C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "XXX.Core.3.0.0.0.Fakes". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\-----\Api.Tests\Api.Tests.csproj]
      C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "XXX.Core.ApplicationServices.3.0.0.0.Fakes". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\-----\Api.Tests\Api.Tests.csproj]
    "C:\-----\Api.Tests\Api.Tests.csproj" (default target) (1) ->

    (CoreCompile target) -> 
      CanonicalModel\66767-BS.UnitTests.cs(18,22): error CS0234: The type or namespace name 'Fakes' does not exist in the namespace 'XXX.Core' (are you missing an assembly reference?) [C:\-----\Api.Tests\Api.Tests.csproj]
      CanonicalModel\72161-BS.UnitTests.cs(18,22): error CS0234: The type or namespace name 'Fakes' does not exist in the namespace 'XXX.Core' (are you missing an assembly reference?) [C:\-----\Api.Tests\Api.Tests.csproj]
      CanonicalModel\UnitTestBase.cs(8,22): error CS0234: The type or namespace name 'Fakes' does not exist in the namespace 'XXX.Core' (are you missing an assembly reference?) [C:\-----\Api.Tests\Api.Tests.csproj]


    Thank you


    • Edited by HL_Brg Wednesday, July 5, 2017 10:09 AM
    Wednesday, July 5, 2017 10:08 AM
  • Hi HL_Brg,

    I managed to fix my issue by working around it. Please have a look at my workaround here: https://stackoverflow.com/a/44928697/1565056

    Workaround:

    • Source: My local VS2017 Premium Update 1 dev machine.
    • Target: The VS2017 Build Tools VM.

    Copy Fakes folder:

    • From Source: c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\
    • To Target: c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\

    Copy Microsoft.QualityTools.Testing.Fakes.ImportAfter.targets file:

    • From Source: c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\
    • To Target: c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Microsoft.Common.Targets\ImportAfter\

    Copy Microsoft.QualityTools.Testing.Fakes.dll file:

    • From Source: c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\
    • To Target: GAC / %windir%\Microsoft.NET\assembly


    Thursday, July 6, 2017 8:24 AM
  • Hi all,

    It's closed, the build it's already done. It pass for 3 steps:

    ### 1 ###

    In csProj, it was necessary to add a Fake: <Fakes Include="Fakes\XXX.fakes" />

    ### 2 ###

    Addictional, we had injected in csproj something like:

    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

    .....

      <Choose>
        <When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
          <ItemGroup>
            <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
          </ItemGroup>
        </When>
        <Otherwise>
          <ItemGroup>
            <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
          </ItemGroup>
        </Otherwise>
      </Choose>

    Resolution:

    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>

    ### 3 ###

    As mentioned by Khang Yeen

    Copy Microsoft.QualityTools.Testing.Fakes.dll file:

    • From Source: c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\
    • To Target: GAC / %windir%\Microsoft.NET\assembly

    Tank you all

    • Marked as answer by HL_Brg Thursday, July 6, 2017 10:56 AM
    Thursday, July 6, 2017 10:52 AM