Build/Test Issues

NCrunch 4 - optimized instrumentation - BadImageFormatException for x64 for F# project

Started by slyvs on 2,065 views

Hello,
Thanks for great update, first of all. But there may be an issue with building x64 F# unit test projects.
- It works with legacy mode.
- It fails for more than one project in my solution. But, so that happened, one of failing projects could have been converted to AnyCPU, and the problem was resolved for that project.

ENGINE - [13:06:27.635-LocalAnalysisTask-36] ERROR (Analysis): A failure occurred while analysing the assembly [SnapshotComponent: WAVE.ViewModels.FSharp.Tests, 79, 31750222]: System.BadImageFormatException: Could not load file or assembly 'file:///C:\Users\vadim\AppData\Local\NCrunch\13560\86\WAVE.ViewModels.FSharp.Tests\bin\Debug\net472\WAVE.ViewModels.FSharp.Tests.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
File name: 'file:///C:\Users\vadim\AppData\Local\NCrunch\13560\86\WAVE.ViewModels.FSharp.Tests\bin\Debug\net472\WAVE.ViewModels.FSharp.Tests.dll'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at nCrunch.Common.ExecutionPlatform.LoadAssembly(FilePath assemblyFilePath)
   at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(DescribedTestFrameworkDiscoverer[] applicableFrameworks, ComponentUniqueName testComponentUniqueName, PerfTracker perfTracker)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].



The project file is following:
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
    <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
    <DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <IsPackable>false</IsPackable>
    <Platforms>x64</Platforms>
    <PlatformTarget>x64</PlatformTarget>
    <Deterministic Condition="'$(NCrunch)' == '1'">false</Deterministic>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>portable</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
    <DebugType>portable</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="..\GlobalAssemblyInfo.fs" Link="GlobalAssemblyInfo.fs" />
    <Compile Include="SelfUpdateViewModelTests.fs" />
  </ItemGroup>
  
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
    <PackageReference Include="Unquote" Version="5.0.0" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\WAVE.ViewModels\WAVE.ViewModels.csproj" />
  </ItemGroup>
</Project>
Hi, thanks for sharing this issue.

As expected, we've had a bit of a wave of these sort of issues with the new optimised mode. I'll take a look at this one as soon as I can and will get back to you :)
Thanks again for reporting this issue. I'm sorry it's taken so long to organise a fix, but the build below should hopefully resolve this for you:

NCrunch_Console_4.2.0.2.msi
NCrunch_Console_4.2.0.2.zip
NCrunch_GridNodeServer_4.2.0.2.msi
NCrunch_GridNodeServer_4.2.0.2.zip
NCrunch_LicenseServer_4.2.0.2.zip
NCrunch_VS2008_4.2.0.2.msi
NCrunch_VS2010_4.2.0.2.msi
NCrunch_VS2010_4.2.0.2.zip
NCrunch_VS2012_4.2.0.2.msi
NCrunch_VS2012_4.2.0.2.zip
NCrunch_VS2013_4.2.0.2.msi
NCrunch_VS2013_4.2.0.2.zip
NCrunch_VS2015_4.2.0.2.msi
NCrunch_VS2015_4.2.0.2.msi.7z
NCrunch_VS2015_4.2.0.2.zip
NCrunch_VS2017_4.2.0.2.msi
NCrunch_VS2017_4.2.0.2.msi.7z
NCrunch_VS2017_4.2.0.2.zip
NCrunch_VS2019_4.2.0.2.msi
NCrunch_VS2019_4.2.0.2.msi.7z
NCrunch_VS2019_4.2.0.2.zip
Thanks a lot. This seems to work fine now. Great job!

Post a reply

Log in to reply.