Description
I really have no idea where that comes from.
I'm just trying to build a new FAKE version, but apparently FCS tries to load a reference assembly which is never a good idea (they should be used for compiling only).
Repro steps
git clone https://github.com/matthid/FAKE.git
git checkout -b fix_bug 7b5a00b67a364a3d3efb0ca0bfe9b266f2209b77
./build.sh
This builds FAKE and tries to run it with the build script (a bootstrapping sanity check if the compiled binary works)
Expected behavior
The build succeeds.
Actual behavior
FAKE.exe Information: 0 : Reactor: enqueue ParseAndCheckProject /tmp/tmp779dac93.fsproj, length 0
FAKE.exe Information: 0 : Reactor: --> ParseAndCheckProject /tmp/tmp779dac93.fsproj, remaining 0, mem 67, gc2 6
Considering _appConfigKey fsharp-compiler-location which has value ''
Fail: Failed to compute key in OpenILModuleReaderAfterReadingAllBytes cache. Falling back to uncached.
Fail: Failed to compute key in OpenILModuleReaderAfterReadingAllBytes cache. Falling back to uncached.
Fail: Failed to compute key in OpenILModuleReaderAfterReadingAllBytes cache. Falling back to uncached.
Fail: Failed to compute key in OpenILModuleReaderAfterReadingAllBytes cache. Falling back to uncached.
Fail: Failed to compute key in OpenILModuleReaderAfterReadingAllBytes cache. Falling back to uncached.
FAKE.exe Information: 0 : Reactor: <-- ParseAndCheckProject /tmp/tmp779dac93.fsproj, remaining 0, took 817.641ms
FAKE.exe Information: 0 : Reactor: receiving..., remaining 0, mem 95, gc2 8
Fail: Bug seen in compiler: System.BadImageFormatException:
File name: '/usr/lib/mono/4.5-api/Mono.Cecil.dll'
at (wrapper managed-to-native) System.Reflection.Assembly:LoadFrom (string,bool)
at System.Reflection.Assembly.LoadFrom (System.String assemblyFile) [0x00000] in <dbb16e0bacdc4a0f87478e401bc29b6c>:0
at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+Shim+DefaultFileSystem.Microsoft-FSharp-Compiler-AbstractIL-Internal-Library-Shim-IFileSystem-AssemblyLoadFrom (System.String fileName) [0x00001] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter.convTypeRefAux (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+cenv cenv, Microsoft.FSharp.Compiler.AbstractIL.IL+ILTypeRef tref) [0x000b7] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter.convTypeSpec (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+cenv cenv, Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, System.Boolean preferCreated, Microsoft.FSharp.Compiler.AbstractIL.IL+ILTypeSpec tspec) [0x0000a] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter.convTypeAux (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+cenv cenv, Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, System.Boolean preferCreated, Microsoft.FSharp.Compiler.AbstractIL.IL+ILType typ) [0x00155] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter.emitLocal (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+cenv cenv, Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, System.Reflection.Emit.ILGenerator ilG, Microsoft.FSharp.Compiler.AbstractIL.IL+ILLocal local) [0x00001] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+localBs@1302.Invoke (Microsoft.FSharp.Compiler.AbstractIL.IL+ILLocal local) [0x00001] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter.emitILMethodBody (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+cenv cenv, System.Reflection.Emit.ModuleBuilder modB, Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, System.Reflection.Emit.ILGenerator ilG, Microsoft.FSharp.Compiler.AbstractIL.IL+ILMethodBody ilmbody) [0x0005d] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter.emitMethodBody[a,b] (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+cenv cenv, System.Reflection.Emit.ModuleBuilder modB, Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] ilG, b _name, Microsoft.FSharp.Compiler.AbstractIL.IL+ILLazyMethodBody mbody) [0x00044] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter.buildMethodPass3 (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+cenv cenv, Microsoft.FSharp.Compiler.AbstractIL.IL+ILTypeRef tref, System.Reflection.Emit.ModuleBuilder modB, System.Reflection.Emit.TypeBuilder typB, Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, Microsoft.FSharp.Compiler.AbstractIL.IL+ILMethodDef mdef) [0x001b4] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+buildTypeDefPass3@1818.Invoke (Microsoft.FSharp.Compiler.AbstractIL.IL+ILMethodDef mdef) [0x00001] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Collections.SeqModule.Iterate[T] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] action, System.Collections.Generic.IEnumerable`1[T] source) [0x0002d] in <5893d081904cf4daa745038381d09358>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter.buildTypeDefPass3 (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+cenv cenv, Microsoft.FSharp.Collections.FSharpList`1[T] nesting, System.Reflection.Emit.ModuleBuilder modB, Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, Microsoft.FSharp.Compiler.AbstractIL.IL+ILTypeDef tdef) [0x00054] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv@1828-7.Invoke (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, Microsoft.FSharp.Compiler.AbstractIL.IL+ILTypeDef tdef) [0x00001] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Collections.ListModule.loop@219-29[T,TState] (Microsoft.FSharp.Core.OptimizedClosures+FSharpFunc`3[T1,T2,TResult] f, TState s, Microsoft.FSharp.Collections.FSharpList`1[T] xs) [0x00019] in <5893d081904cf4daa745038381d09358>:0
at Microsoft.FSharp.Collections.ListModule.Fold[T,TState] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] folder, TState state, Microsoft.FSharp.Collections.FSharpList`1[T] list) [0x00014] in <5893d081904cf4daa745038381d09358>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter.buildTypeDefPass3 (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+cenv cenv, Microsoft.FSharp.Collections.FSharpList`1[T] nesting, System.Reflection.Emit.ModuleBuilder modB, Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, Microsoft.FSharp.Compiler.AbstractIL.IL+ILTypeDef tdef) [0x0016d] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter.buildModuleTypePass3 (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+cenv cenv, System.Reflection.Emit.ModuleBuilder modB, Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, Microsoft.FSharp.Compiler.AbstractIL.IL+ILTypeDef tdef) [0x00007] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv@1984-10.Invoke (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, Microsoft.FSharp.Compiler.AbstractIL.IL+ILTypeDef tdef) [0x00001] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Collections.ListModule.loop@219-29[T,TState] (Microsoft.FSharp.Core.OptimizedClosures+FSharpFunc`3[T1,T2,TResult] f, TState s, Microsoft.FSharp.Collections.FSharpList`1[T] xs) [0x00019] in <5893d081904cf4daa745038381d09358>:0
at Microsoft.FSharp.Collections.ListModule.Fold[T,TState] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] folder, TState state, Microsoft.FSharp.Collections.FSharpList`1[T] list) [0x00014] in <5893d081904cf4daa745038381d09358>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter.buildModuleFragment (Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+cenv cenv, Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, System.Reflection.Emit.AssemblyBuilder asmB, System.Reflection.Emit.ModuleBuilder modB, Microsoft.FSharp.Compiler.AbstractIL.IL+ILModuleDef m) [0x00128] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter.emitModuleFragment (Microsoft.FSharp.Compiler.AbstractIL.IL+ILGlobals ilg, Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter+emEnv emEnv, System.Reflection.Emit.AssemblyBuilder asmB, System.Reflection.Emit.ModuleBuilder modB, Microsoft.FSharp.Compiler.AbstractIL.IL+ILModuleDef modul, System.Boolean debugInfo, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] resolveAssemblyRef, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] tryFindSysILTypeRef) [0x0000e] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.Interactive.Shell+FsiDynamicCompiler.ProcessInputs (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok, Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger errorLogger, Microsoft.FSharp.Compiler.Interactive.Shell+FsiDynamicCompilerState istate, Microsoft.FSharp.Collections.FSharpList`1[T] inputs, System.Boolean showTypes, System.Boolean isIncrementalFragment, System.Boolean isInteractiveItExpr, Microsoft.FSharp.Collections.FSharpList`1[T] prefixPath) [0x00306] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.Interactive.Shell+FsiDynamicCompiler.EvalParsedSourceFiles (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok, Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger errorLogger, Microsoft.FSharp.Compiler.Interactive.Shell+FsiDynamicCompilerState istate, Microsoft.FSharp.Collections.FSharpList`1[T] inputs) [0x00088] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.Interactive.Shell+FsiDynamicCompiler.EvalSourceFiles (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok, Microsoft.FSharp.Compiler.Interactive.Shell+FsiDynamicCompilerState istate, Microsoft.FSharp.Compiler.Range+range m, Microsoft.FSharp.Collections.FSharpList`1[T] sourceFiles, Microsoft.FSharp.Compiler.Lexhelp+LexResourceManager lexResourceManager, Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger errorLogger) [0x00173] in <5903835dddab8ea7a74503835d830359>:0
at [email protected] (Microsoft.FSharp.Compiler.Interactive.Shell+FsiDynamicCompilerState istate) [0x0074b] in <5903835dddab8ea7a74503835d830359>:0
at Microsoft.FSharp.Compiler.Interactive.Shell+FsiInteractionProcessor.InteractiveCatch[b] (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger errorLogger, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] f, b istate) [0x0001f] in <5903835dddab8ea7a74503835d830359>:0
Known workarounds
I have no idea.
Related information
Interestingly we updated FCS in the main branch as well and there we don't have this problem.
In the main branch we use an other version of Mono.Cecil
and not the latest prerelease one which supports netstandard (which we need for the netcore version obviously).
To be honest I'm lost there. I cannot reproduce the error with FSI either. The debugging information was retrieved by a debug build from @cloudRoutine which is from the master branch. This initially happened on 12.0.5
which wouldn't really print anything but internal error
, see #762
Is this maybe related to #759 (which I'm seeing in my log as well) or #731 (which has the reference assembly path as well in its error messages)
Note: The Error: System.NotSupportedException
is probably a follow-up error when trying to save the broken assembly
Any help is appreciated... (The debugging version is here and available via the https://ci.appveyor.com/nuget/customnuspecs nuget feed)