Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Bad IL format with Cake MacOSX (2.3.0 - 3.1.0) #3996

Closed
2 tasks done
moljac opened this issue Oct 19, 2022 · 11 comments · Fixed by #4206
Closed
2 tasks done

Error: Bad IL format with Cake MacOSX (2.3.0 - 3.1.0) #3996

moljac opened this issue Oct 19, 2022 · 11 comments · Fixed by #4206
Labels
Milestone

Comments

@moljac
Copy link
Contributor

moljac commented Oct 19, 2022

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

Cake runner

Cake .NET Tool

Cake version

2.3.0
3.0.0
3.1.0

Operating system

macOS

Operating system architecture

64-Bit

CI Server

Azure DevOps

What are you seeing?

Running builds for (AndroidX and GooglePlayServices-Firebase-MLKit) both locally and on CI with Cake 2.3.0 there is an error.

Stripped for search:

Error: Bad IL format. 
The format of the file 
    'tools/Addins/runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple.4.3.0/runtimes/osx.10.10-x64/native/System.Security.Cryptography.Native.Apple.dylib' 
is invalid. 
An error occurred when executing task Error: .NET CLI: 
Process returned an error (exit code 1)

from CI server:

Error: Bad IL format. 
The format of the file 
    '/Users/runner/work/1/s/tools/Addins/runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple.4.3.0/runtimes/osx.10.10-x64/native/System.Security.Cryptography.Native.Apple.dylib' 
is invalid. 
An error occurred when executing task Error: .NET CLI: Process returned an error (exit code 1)

What is expected?

correct build

Steps to Reproduce

  1. install or update Cake.Tool to 2.3.0
  2. clone AndroidX or GooglePlayServices-Firebase-MLKit
  3. run builds
    dotnet cake -t=clean && dotnet cake -t=ci 
    

ping me in the comments if you need scripts to repro (installing, cloning, building)

Output log

too long

@augustoproiete
Copy link
Member

Thanks @moljac. If I understand correctly, these builds seem to work fine on Cake v2.2.0 but break on v2.3.0

Any chance you can get a repro of one of these repos running on GitHub Actions?
I gave it a shot on https://github.com/augustoproiete-repros/repro-cake-build-issue-3996-bad-il-format but the build seems to be stuck for hours - I'm probably missing something there

@moljac
Copy link
Contributor Author

moljac commented Apr 3, 2023

Thanks @moljac. If I understand correctly, these builds seem to work fine on Cake v2.2.0 but break on v2.3.0

Well right now I get it with cake 3.0, so I downgrade to 2.3.0.

Any chance you can get a repro of one of these repos running on GitHub Actions?

I can try.

I gave it a shot on https://github.com/augustoproiete-repros/repro-cake-build-issue-3996-bad-il-format but the build seems to be stuck for hours - I'm probably missing something there

Yeah those are looong builds. AX 45 minutes to 1 hour and GPS-FB-MLKit 1.5-2 hrs.

I will try to use 3.0.0 and see if I can repro something.

@moljac
Copy link
Contributor Author

moljac commented Apr 3, 2023

error I get on MacOSX Ventura:

Error: Bad IL format. The format of the file './tools/Addins/runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple.4.3.0/runtimes/osx.10.10-x64/native/System.Security.Cryptography.Native.Apple.dylib' is invalid.
An error occurred when executing task 'tools-executive-order'.
Error: .NET CLI: Process returned an error (exit code 1).

cake version:

dotnet cake --version
3.0.0

Looks like some transitive dependencies cause this.

quite old packages:

https://www.nuget.org/packages/runtime.native.System.Security.Cryptography.Apple/4.3.0

https://www.nuget.org/packages/runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple/4.3.0

Commands that should repro (with cake 3.0 installed):

git clone --recursive https://github.com/xamarin/GooglePlayServicesComponents.git
cd GooglePlayServicesComponents/
dotnet tool uninstall --global Cake.Tool && dotnet tool install --global Cake.Tool --version 3.0.0
dotnet cake -t=ci && dotnet cake utilities.cake -t=tools-executive-order

@augustoproiete
Copy link
Member

Thanks @moljac just to confirm, are you building on Mac with an ARM processor?

@moljac
Copy link
Contributor Author

moljac commented Apr 4, 2023

Thanks @moljac just to confirm, are you building on Mac with an ARM processor?

No. Intel. x86

@moljac
Copy link
Contributor Author

moljac commented May 3, 2023

Hi

seems like

#addin nuget:?package=HolisticWare.Xamarin.Tools.ComponentGovernance&version=0.0.1.2

transitively pulls in some older packages.

xamarin/GooglePlayServicesComponents#766 (comment)

Let me update dependencies for the package and report it here

@moljac
Copy link
Contributor Author

moljac commented May 8, 2023

#addin nuget:?package=HolisticWare.Xamarin.Tools.ComponentGovernance&version=0.0.1.2

No that was not the case! After updates still getting this error.

@moljac
Copy link
Contributor Author

moljac commented May 9, 2023

diagnostic output

dotnet cake utilities.cake -t=tools-executive-order -v:diagnostic
Looking for modules...
No modules found to install.
Module directory does not exist.
Analyzing build script...
Analyzing /Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/utilities.cake...
Processing build script...
Installing addins...
Resolving assembly 'System.Private.Uri.resources, Version=6.0.0.0, Culture=en-HR, PublicKeyToken=b03f5f7f11d50a3a' using runtime installed at '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.16/'...
Exception occurred while resolving assembly System.Private.Uri.resources: Could not load file or assembly 'System.Private.Uri.resources, Version=6.0.0.0, Culture=en-HR, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

Trying to resolve assembly System.Private.Uri.resources as 'System.Private.Uri, Version=6.0.0.0, Culture=en-HR, PublicKeyToken=b03f5f7f11d50a3a'...
Assembly System.Private.Uri resolved as 'System.Private.Uri, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' (file location: '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.16/System.Private.Uri.dll')
Resolving assembly 'NuGet.Resolver.resources, Version=6.3.1.1, Culture=en-HR, PublicKeyToken=31bf3856ad364e35' using runtime installed at '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.16/'...
Exception occurred while resolving assembly NuGet.Resolver.resources: Could not load file or assembly 'NuGet.Resolver.resources, Version=6.3.1.1, Culture=en-HR, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

Trying to resolve assembly NuGet.Resolver.resources as 'NuGet.Resolver, Version=6.3.1.1, Culture=en-HR, PublicKeyToken=31bf3856ad364e35'...
Assembly NuGet.Resolver resolved as 'NuGet.Resolver, Version=6.3.1.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' (file location: '/Users/moljac/.dotnet/tools/.store/cake.tool/3.0.0/cake.tool/3.0.0/tools/net6.0/any/NuGet.Resolver.dll')
Resolving assembly 'NuGet.Common.resources, Version=6.3.1.1, Culture=en-HR, PublicKeyToken=31bf3856ad364e35' using runtime installed at '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.16/'...
Exception occurred while resolving assembly NuGet.Common.resources: Could not load file or assembly 'NuGet.Common.resources, Version=6.3.1.1, Culture=en-HR, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

Trying to resolve assembly NuGet.Common.resources as 'NuGet.Common, Version=6.3.1.1, Culture=en-HR, PublicKeyToken=31bf3856ad364e35'...
Assembly NuGet.Common resolved as 'NuGet.Common, Version=6.3.1.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' (file location: '/Users/moljac/.dotnet/tools/.store/cake.tool/3.0.0/cake.tool/3.0.0/tools/net6.0/any/NuGet.Common.dll')
Assemblies not found at /Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/tools/Addins/Microsoft.NETCore.Platforms.5.0.0.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Package Cake.Core depends on package Cake.Core.3.0.0 : Microsoft.CSharp [4.7.0, ), Microsoft.Win32.Registry [5.0.0, ). This dependency won't be loaded.
The addin Cake.Core will reference tools/Addins/Microsoft.CSharp.4.7.0/lib/netstandard2.0/Microsoft.CSharp.dll.
The addin Cake.Core will reference tools/Addins/System.Security.Principal.Windows.5.0.0/runtimes/unix/lib/netcoreapp2.1/System.Security.Principal.Windows.dll.
The addin Cake.Core will reference tools/Addins/System.Security.AccessControl.5.0.0/lib/netstandard2.0/System.Security.AccessControl.dll.
The addin Cake.Core will reference tools/Addins/Microsoft.Win32.Registry.5.0.0/lib/netstandard2.0/Microsoft.Win32.Registry.dll.
The addin WeCantSpell.Hunspell will reference tools/Addins/WeCantSpell.Hunspell.4.0.0/lib/net6.0/WeCantSpell.Hunspell.dll.
The addin Newtonsoft.Json will reference tools/Addins/Newtonsoft.Json.13.0.3/lib/net6.0/Newtonsoft.Json.dll.
The addin Cake.FileHelpers will reference tools/Addins/Cake.FileHelpers.6.1.3/lib/net6.0/Cake.FileHelpers.dll.
The addin Mono.Cecil will reference tools/Addins/Mono.Cecil.0.11.5/lib/netstandard2.0/Mono.Cecil.dll.
The addin Mono.Cecil will reference tools/Addins/Mono.Cecil.0.11.5/lib/netstandard2.0/Mono.Cecil.Mdb.dll.
The addin Mono.Cecil will reference tools/Addins/Mono.Cecil.0.11.5/lib/netstandard2.0/Mono.Cecil.Rocks.dll.
The addin Mono.Cecil will reference tools/Addins/Mono.Cecil.0.11.5/lib/netstandard2.0/Mono.Cecil.Pdb.dll.
The addin System.Text.Json will reference tools/Addins/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net6.0/System.Runtime.CompilerServices.Unsafe.dll.
The addin System.Text.Json will reference tools/Addins/System.Text.Encodings.Web.7.0.0/lib/net6.0/System.Text.Encodings.Web.dll.
The addin System.Text.Json will reference tools/Addins/System.Text.Json.7.0.2/lib/net6.0/System.Text.Json.dll.
Assemblies not found at /Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/tools/Addins/Microsoft.NETCore.Platforms.1.1.1.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found at /Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/tools/Addins/Microsoft.NETCore.Targets.1.1.0.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found at /Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/tools/Addins/runtime.native.System.4.3.0.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found at /Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/tools/Addins/runtime.native.System.Net.Http.4.3.0.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found at /Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/tools/Addins/runtime.native.System.Security.Cryptography.Apple.4.3.0.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found at /Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/tools/Addins/runtime.native.System.Security.Cryptography.OpenSsl.4.3.2.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/HolisticWare.Core.IO.0.0.4/lib/netstandard2.0/HolisticWare.Core.IO.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/HtmlAgilityPack.1.11.46/lib/netstandard2.0/HtmlAgilityPack.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple.4.3.0/runtimes/osx.10.10-x64/native/System.Security.Cryptography.Native.Apple.dylib.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl.4.3.2/runtimes/osx.10.10-x64/native/System.Security.Cryptography.Native.OpenSsl.dylib.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/HolisticWare.Core.Net.HTTP.0.0.4/lib/netstandard2.0/HolisticWare.Core.Net.HTTP.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.IO.FileSystem.Primitives.4.3.0/lib/netstandard1.3/System.IO.FileSystem.Primitives.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net6.0/System.Runtime.CompilerServices.Unsafe.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Text.Encodings.Web.7.0.0/lib/net6.0/System.Text.Encodings.Web.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Text.Json.7.0.2/lib/net6.0/System.Text.Json.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Linq.4.3.0/lib/netstandard1.6/System.Linq.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Globalization.Extensions.4.3.0/runtimes/unix/lib/netstandard1.3/System.Globalization.Extensions.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Runtime.Numerics.4.3.0/lib/netstandard1.3/System.Runtime.Numerics.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Threading.4.3.0/lib/netstandard1.3/System.Threading.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Collections.Concurrent.4.3.0/lib/netstandard1.3/System.Collections.Concurrent.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Diagnostics.DiagnosticSource.4.3.0/lib/netstandard1.3/System.Diagnostics.DiagnosticSource.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Security.Cryptography.Primitives.4.3.0/lib/netstandard1.3/System.Security.Cryptography.Primitives.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Security.Cryptography.Encoding.4.3.0/runtimes/unix/lib/netstandard1.3/System.Security.Cryptography.Encoding.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Security.Cryptography.Algorithms.4.3.0/runtimes/osx/lib/netstandard1.6/System.Security.Cryptography.Algorithms.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Security.Cryptography.Cng.4.3.0/runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.Cng.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Security.Cryptography.Csp.4.3.0/runtimes/unix/lib/netstandard1.3/System.Security.Cryptography.Csp.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Security.Cryptography.OpenSsl.4.3.0/runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.OpenSsl.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Security.Cryptography.X509Certificates.4.3.0/runtimes/unix/lib/netstandard1.6/System.Security.Cryptography.X509Certificates.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/System.Net.Http.4.3.4/runtimes/unix/lib/netstandard1.6/System.Net.Http.dll.
The addin HolisticWare.Xamarin.Tools.ComponentGovernance will reference tools/Addins/HolisticWare.Xamarin.Tools.ComponentGovernance.0.0.1.4/lib/netstandard2.0/HolisticWare.Xamarin.Tools.ComponentGovernance.dll.
Assemblies not found at /Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/tools/Addins/Microsoft.NETCore.Platforms.1.1.0.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found at /Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/tools/Addins/Microsoft.NETCore.Targets.1.1.0.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
Assemblies not found for tfm net6.0 and rid osx.13-x64.
No assemblies found after running content resolver.
The addin HolisticWare.Core.Net.HTTP will reference tools/Addins/HolisticWare.Core.IO.0.0.4/lib/netstandard2.0/HolisticWare.Core.IO.dll.
The addin HolisticWare.Core.Net.HTTP will reference tools/Addins/HtmlAgilityPack.1.11.46/lib/netstandard2.0/HtmlAgilityPack.dll.
The addin HolisticWare.Core.Net.HTTP will reference tools/Addins/HolisticWare.Core.Net.HTTP.0.0.4/lib/netstandard2.0/HolisticWare.Core.Net.HTTP.dll.
The addin HolisticWare.Core.IO will reference tools/Addins/HolisticWare.Core.IO.0.0.4/lib/netstandard2.0/HolisticWare.Core.IO.dll.
Skipping verification of assembly 'Microsoft.CSharp, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Skipping verification of assembly 'System.Security.Principal.Windows, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Skipping verification of assembly 'System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Skipping verification of assembly 'Microsoft.Win32.Registry, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Skipping verification of assembly 'WeCantSpell.Hunspell, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null'.
Skipping verification of assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.
Skipping verification of assembly 'Cake.FileHelpers, Version=6.1.3.0, Culture=neutral, PublicKeyToken=null'.
Skipping verification of assembly 'Mono.Cecil, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'.
Skipping verification of assembly 'Mono.Cecil.Mdb, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'.
Skipping verification of assembly 'Mono.Cecil.Rocks, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'.
Skipping verification of assembly 'Mono.Cecil.Pdb, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'.
Skipping verification of assembly 'System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Caught error while loading /Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/tools/Addins/System.Text.Encodings.Web.7.0.0/lib/net6.0/System.Text.Encodings.Web.dll
System.IO.FileLoadException: Could not load file or assembly 'System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Cake.Core.Polyfill.AssemblyHelper.LoadAssembly(ICakeEnvironment environment, IFileSystem fileSystem, ICakeLog log, FilePath path) in C:\projects\cake\src\Cake.Core\Polyfill\AssemblyHelper.cs:line 49
Caught error while loading /Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/tools/Addins/System.Text.Json.7.0.2/lib/net6.0/System.Text.Json.dll
System.IO.FileLoadException: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Cake.Core.Polyfill.AssemblyHelper.LoadAssembly(ICakeEnvironment environment, IFileSystem fileSystem, ICakeLog log, FilePath path) in C:\projects\cake\src\Cake.Core\Polyfill\AssemblyHelper.cs:line 49
Skipping verification of assembly 'HolisticWare.Core.IO, Version=0.0.4.0, Culture=neutral, PublicKeyToken=null'.
Skipping verification of assembly 'HtmlAgilityPack, Version=1.11.46.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a'.
Error: System.BadImageFormatException: Bad IL format. The format of the file '/Users/Shared/Projects/d/X/GPS-FB-MLKit/mu-20230503-executive-order-fix/tools/Addins/runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple.4.3.0/runtimes/osx.10.10-x64/native/System.Security.Cryptography.Native.Apple.dylib' is invalid.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Cake.Core.Polyfill.AssemblyHelper.LoadAssembly(ICakeEnvironment environment, IFileSystem fileSystem, ICakeLog log, FilePath path) in C:\projects\cake\src\Cake.Core\Polyfill\AssemblyHelper.cs:line 49
   at Cake.Core.Reflection.AssemblyLoader.Load(FilePath path, Boolean verify) in C:\projects\cake\src\Cake.Core\Reflection\AssemblyLoader.cs:line 47
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath) in C:\projects\cake\src\Cake.Core\Scripting\ScriptRunner.cs:line 125
   at Cake.Features.Building.BuildFeature.RunCore(IRemainingArguments arguments, BuildFeatureSettings settings) in C:\projects\cake\src\Cake\Features\Building\BuildFeature.cs:line 99
   at Cake.Features.Building.BuildFeature.Run(IRemainingArguments arguments, BuildFeatureSettings settings) in C:\projects\cake\src\Cake\Features\Building\BuildFeature.cs:line 49
   at Cake.Commands.DefaultCommand.Execute(CommandContext context, DefaultCommandSettings settings) in C:\projects\cake\src\Cake\Commands\DefaultCommand.cs:line 73

@moljac
Copy link
Contributor Author

moljac commented May 9, 2023

project.assets.json for app with the same package references

project.assets.json.zip

@jonpryor
Copy link

jonpryor commented May 9, 2023

The bug is in FIleExtensions.IsClrAssembly():

public static bool IsClrAssembly(this IFile file)

Consider this program:

using Cake.Core.IO;

class App {
    public static void Main (string[] args) {
        var fs = new FileSystem();
        foreach (var s in args) {
            var f = fs.GetFile(s);
            Console.WriteLine (f.IsClrAssembly());
        }
    }
}

Compile it against Cake.Core.dll, then Download and extract the runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple 4.3.0 NuGet Package.

The bug is that FileExtensions.IsClrAssembly thinks System.Security.Cryptography.Native.Apple.dylib is a CLR assembly!

% dotnet run ~/Downloads/runtimes/osx.10.10-x64/native/System.Security.Cryptography.Native.Apple.dylib
True

@moljac moljac changed the title Error: Bad IL format with Cake 2.3.0 MacOSX Error: Bad IL format with Cake MacOSX (2.3.0 - 3.1.0) Sep 18, 2023
@devlead devlead modified the milestones: Next Minor Candidate, v3.2.0 Sep 29, 2023
@devlead devlead linked a pull request Oct 1, 2023 that will close this issue
@cake-build-bot
Copy link

🎉 This issue has been resolved in version v3.2.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants