cake-build / cake

:cake: Cake (C# Make) is a cross platform build automation system.
https://cakebuild.net
MIT License
3.92k stars 731 forks source link

Crash in macOS: TypeLoadException: Could not resolve type Cake.Core.CakeTaskBuilder`1, Cake.Core, Version=0.26.1.0, Culture=neutral, PublicKeyToken=null #2264

Open knocte opened 6 years ago

knocte commented 6 years ago

What You Are Seeing?

A crash.

I try to build the repository ZXing.Net.Mobile, which has a stock build.sh file for bootstrapping CAKE. The log:

$ ./build.sh 
Restoring tools from NuGet...
Feeds used:
  /Users/andres/.nuget/packages/
  https://www.myget.org/F/nethereum/api/v3/index.json
  https://api.nuget.org/v3/index.json

All packages listed in /Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/packages.config are already installed.
Running Cake...
The assembly 'Cake.Android.SdkManager, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' 
is referencing an older version of Cake.Core (0.26.1). 
For best compatibility it should target Cake.Core version 0.28.0.
The assembly 'Cake.XCode, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null' 
is referencing an older version of Cake.Core (0.26.1). 
For best compatibility it should target Cake.Core version 0.28.0.
The assembly 'Cake.Xamarin, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' 
is referencing an older version of Cake.Core (0.26.1). 
For best compatibility it should target Cake.Core version 0.28.0.
The assembly 'Cake.Xamarin.Build, Version=4.0.1.0, Culture=neutral, PublicKeyToken=null' 
is referencing an older version of Cake.Core (0.26.1). 
For best compatibility it should target Cake.Core version 0.28.0.
The assembly 'Cake.SemVer, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' 
is referencing an older version of Cake.Core (0.26.1). 
For best compatibility it should target Cake.Core version 0.28.0.
Error: Could not resolve type with token 01000016 (from typeref, class/assembly Cake.Core.CakeTaskBuilder`1, Cake.Core, Version=0.26.1.0, Culture=neutral, PublicKeyToken=null)

What is Expected?

To not crash?

What version of Cake are you using?

The last one? build.sh seems to download the last one. Which at the time of writing seems to be 0.30.0.

Are you running on a 32 or 64 bit system?

64 I guess.

What environment are you running on? Windows? Linux? Mac?

macOS

Are you running on a CI Server? If so, which one?

No

How Did You Get This To Happen? (Steps to Reproduce)

Clone https://github.com/Redth/ZXing.Net.Mobile , run its build.sh.

Output Log

Log with --verbosity=diagnostic:

$ ./build.sh 
Restoring tools from NuGet...
Feeds used:
  /Users/andres/.nuget/packages/
  https://www.myget.org/F/nethereum/api/v3/index.json
  https://api.nuget.org/v3/index.json

All packages listed in /Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/packages.config are already installed.
Running Cake...
Module directory does not exist.
NuGet.config not found.
Analyzing build script...
Analyzing /Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/build.cake...
Processing build script...
Installing tools...
  GET https://www.myget.org/F/nethereum/api/v3/registration1/xamarincomponent/index.json
  NotFound https://www.myget.org/F/nethereum/api/v3/registration1/xamarincomponent/index.json 1404ms
  CACHE https://api.nuget.org/v3/registration3-gz-semver2/xamarincomponent/index.json
Found package 'XamarinComponent 1.1.0.65' in '/Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools'.
Package XamarinComponent.1.1.0.65 has already been installed.
Successfully installed 'XamarinComponent 1.1.0.65' to /Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools
Executing nuget actions took 18.95 ms
Installing addins...
  GET https://www.myget.org/F/nethereum/api/v3/registration1/cake.android.sdkmanager/index.json
  NotFound https://www.myget.org/F/nethereum/api/v3/registration1/cake.android.sdkmanager/index.json 1106ms
  CACHE https://api.nuget.org/v3/registration3-gz-semver2/cake.android.sdkmanager/index.json
Found package 'Cake.Android.SdkManager 3.0.0' in '/Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins'.
Package Cake.Android.SdkManager.3.0.0 has already been installed.
Successfully installed 'Cake.Android.SdkManager 3.0.0' to /Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins
Executing nuget actions took 0.84 ms
The addin Cake.Android.SdkManager will reference Cake.Android.SdkManager.dll.
  GET https://www.myget.org/F/nethereum/api/v3/registration1/cake.xcode/index.json
  NotFound https://www.myget.org/F/nethereum/api/v3/registration1/cake.xcode/index.json 1063ms
  CACHE https://api.nuget.org/v3/registration3-gz-semver2/cake.xcode/index.json
Found package 'Cake.XCode 4.0.0' in '/Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins'.
Package Cake.XCode.4.0.0 has already been installed.
Successfully installed 'Cake.XCode 4.0.0' to /Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins
Executing nuget actions took 0.8 ms
The addin Cake.XCode will reference Cake.XCode.dll.
  GET https://www.myget.org/F/nethereum/api/v3/registration1/cake.xamarin/index.json
  NotFound https://www.myget.org/F/nethereum/api/v3/registration1/cake.xamarin/index.json 1234ms
  CACHE https://api.nuget.org/v3/registration3-gz-semver2/cake.xamarin/index.json
Found package 'Cake.Xamarin 3.0.0' in '/Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins'.
Package Cake.Xamarin.3.0.0 has already been installed.
Successfully installed 'Cake.Xamarin 3.0.0' to /Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins
Executing nuget actions took 0.84 ms
The addin Cake.Xamarin will reference Cake.Xamarin.dll.
  GET https://www.myget.org/F/nethereum/api/v3/registration1/cake.xamarin.build/index.json
  NotFound https://www.myget.org/F/nethereum/api/v3/registration1/cake.xamarin.build/index.json 1108ms
  CACHE https://api.nuget.org/v3/registration3-gz-semver2/cake.xamarin.build/index.json
Found package 'Cake.Xamarin.Build 4.0.1' in '/Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins'.
Package Cake.Xamarin.Build.4.0.1 has already been installed.
Successfully installed 'Cake.Xamarin.Build 4.0.1' to /Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins
Executing nuget actions took 0.82 ms
The addin Cake.Xamarin.Build will reference Cake.Xamarin.Build.dll.
  GET https://www.myget.org/F/nethereum/api/v3/registration1/cake.semver/index.json
  NotFound https://www.myget.org/F/nethereum/api/v3/registration1/cake.semver/index.json 1190ms
  CACHE https://api.nuget.org/v3/registration3-gz-semver2/cake.semver/index.json
Found package 'Cake.SemVer 3.0.0' in '/Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins'.
Package Cake.SemVer.3.0.0 has already been installed.
Successfully installed 'Cake.SemVer 3.0.0' to /Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins
Executing nuget actions took 0.82 ms
The addin Cake.SemVer will reference Cake.SemVer.dll.
  GET https://www.myget.org/F/nethereum/api/v3/registration1/cake.filehelpers/index.json
  NotFound https://www.myget.org/F/nethereum/api/v3/registration1/cake.filehelpers/index.json 1022ms
  CACHE https://api.nuget.org/v3/registration3-gz-semver2/cake.filehelpers/index.json
Found package 'Cake.FileHelpers 3.1.0' in '/Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins'.
Package Cake.FileHelpers.3.1.0 has already been installed.
Successfully installed 'Cake.FileHelpers 3.1.0' to /Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins
Executing nuget actions took 0.89 ms
The addin Cake.FileHelpers will reference Cake.FileHelpers.dll.
  GET https://www.myget.org/F/nethereum/api/v3/registration1/cake.monoapitools/index.json
  NotFound https://www.myget.org/F/nethereum/api/v3/registration1/cake.monoapitools/index.json 1074ms
  CACHE https://api.nuget.org/v3/registration3-gz-semver2/cake.monoapitools/index.json
Found package 'Cake.MonoApiTools 3.0.1' in '/Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins'.
Package Cake.MonoApiTools.3.0.1 has already been installed.
Successfully installed 'Cake.MonoApiTools 3.0.1' to /Users/andres/Documents/Code/gwalletFRONTEND/build/ZXing.Net.Mobile/tools/Addins
Executing nuget actions took 0.92 ms
The addin Cake.MonoApiTools will reference Cake.MonoApiTools.dll.
Verifying assembly 'Cake.Android.SdkManager, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null'.
The assembly 'Cake.Android.SdkManager, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' 
is referencing an older version of Cake.Core (0.26.1). 
For best compatibility it should target Cake.Core version 0.28.0.
Verifying assembly 'Cake.XCode, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null'.
The assembly 'Cake.XCode, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null' 
is referencing an older version of Cake.Core (0.26.1). 
For best compatibility it should target Cake.Core version 0.28.0.
Verifying assembly 'Cake.Xamarin, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null'.
The assembly 'Cake.Xamarin, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' 
is referencing an older version of Cake.Core (0.26.1). 
For best compatibility it should target Cake.Core version 0.28.0.
Verifying assembly 'Cake.Xamarin.Build, Version=4.0.1.0, Culture=neutral, PublicKeyToken=null'.
The assembly 'Cake.Xamarin.Build, Version=4.0.1.0, Culture=neutral, PublicKeyToken=null' 
is referencing an older version of Cake.Core (0.26.1). 
For best compatibility it should target Cake.Core version 0.28.0.
Verifying assembly 'Cake.SemVer, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null'.
The assembly 'Cake.SemVer, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' 
is referencing an older version of Cake.Core (0.26.1). 
For best compatibility it should target Cake.Core version 0.28.0.
Verifying assembly 'Cake.FileHelpers, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null'.
Verifying assembly 'Cake.MonoApiTools, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null'.
Error: System.TypeLoadException: Could not resolve type with token 01000016 (from typeref, class/assembly Cake.Core.CakeTaskBuilder`1, Cake.Core, Version=0.26.1.0, Culture=neutral, PublicKeyToken=null)
  at (wrapper managed-to-native) System.Reflection.MonoMethodInfo.get_parameter_info(intptr,System.Reflection.MemberInfo)
  at System.Reflection.MonoMethodInfo.GetParametersInfo (System.IntPtr handle, System.Reflection.MemberInfo member) [0x00000] in <bb7b695b8c6246b3ac1646577aea7650>:0 
  at System.Reflection.MonoMethod.GetParameters () [0x00000] in <bb7b695b8c6246b3ac1646577aea7650>:0 
  at Cake.Core.Scripting.ScriptAliasFinder+<GetAliasMethods>d__4.MoveNext () [0x00070] in <1a12afcf649f4de8ab5d15d82d4f6310>:0 
  at Cake.Core.Scripting.ScriptAliasFinder.FindAliases (System.Collections.Generic.IEnumerable`1[T] assemblies) [0x00072] in <1a12afcf649f4de8ab5d15d82d4f6310>:0 
  at Cake.Core.Scripting.ScriptRunner.Run (Cake.Core.Scripting.IScriptHost host, Cake.Core.IO.FilePath scriptPath, System.Collections.Generic.IDictionary`2[TKey,TValue] arguments) [0x00238] in <1a12afcf649f4de8ab5d15d82d4f6310>:0 
  at Cake.Commands.BuildCommand.Execute (Cake.CakeOptions options) [0x0003f] in <52bc22bce5254240ba373b3cf23da1ab>:0 
  at Cake.CakeApplication.Run (Cake.CakeOptions options) [0x00015] in <52bc22bce5254240ba373b3cf23da1ab>:0 
  at Cake.Program.Main () [0x000d1] in <52bc22bce5254240ba373b3cf23da1ab>:0 
gep13 commented 6 years ago

@knocte is there a reason that you are raising this issue here, rather than on that repository? While we would love to, the Cake Team isn't responsible for every build script that is created using Cake.

knocte commented 6 years ago

the Cake Team isn't responsible for every build script

I know that. However, a TypeLoadException inside Cake seems like a bug in Cake, and not a bug in a build script. In fact, I've proposed a PR to fix their build, but just by using the workaround of pinning to 0.26.1 (while 0.30.0 is still crashing). I'm guessing that you don't want all Cake users to stay in 0.26.1...?

devlead commented 6 years ago

Is it an bug in Cake? Looks like Cake.MonoApiTools 3.0.0 targets 0.26.1.0. But 3.0.1 targets 0.30.0, tried updating all addins to latest version.

knocte commented 6 years ago

Looks like Cake.MonoApiTools...

Oh I didn't know about these tools

Cake.MonoApiTools 3.0.0 targets 0.26.1.0

Where's that version? Not listed in https://www.nuget.org/packages/Cake.MonoApiTools

gep13 commented 6 years ago

Having had a quick look at the source code, I think the issue is here:

https://github.com/Redth/Cake.Xamarin.Build/blob/ded2366253a10f524870376d2afa42a1ffcbc90e/src/Cake.Xamarin.Build/XamarinBuildTasks.cs#L96

The generic type CakeTaskBuilder<ActionTask> was removed in Cake 0.28.0. As a result, in order for the build for that project to work on anything higher than what it currently works on, you would need to update the Cake.Xamarin.Build project to use a newer version of Cake, and then reference it within the build.

As a general rule, the Cake Team have always recommended pinning the version of Cake, Cake Addins, Cake Tools and Cake Modules, so that issues like this don't crop up when newer versions of those things are released.