ConfuserEx
ConfuserEx copied to clipboard
System.BadImageFormatException using .NET core 2.2.207 SDK x64 to build app for Linux or Windows
I am trying to build a ConfuserEx release/2.0 branch build of the netcoreapp2.2 to run on Linux to help us script obfuscation of assemblies with some automation. However, I have tested on Windows as well to make sure it was not platform specific. I applied the command to publish (from another issue):
msbuild Confuser.CLI\Confuser.CLI.csproj -v:m -t:Publish -p:Configuration=Release -p:TargetFramework=netcoreapp2.2 -p:PublishDir="confuser2.0-bin"
I did not receive any errors and received a published folder where expected:
<snip>
Confuser.CLI -> D:\Dev\ConfuserEx-2.0-dev\Confuser.CLI\bin\x86\Release\netcoreapp2.2\Confuser.CLI.dll
Confuser.CLI -> D:\Dev\ConfuserEx-2.0-dev\Confuser.CLI\confuser2.0-bin\
Directory structure/contents of published folder is:
12/23/2018 04:46 PM 213,504 Antlr4.Runtime.dll
09/25/2020 07:33 PM 80,243 Confuser.CLI.deps.json
09/25/2020 07:33 PM 19,456 Confuser.CLI.dll
09/25/2020 07:33 PM 34,918 Confuser.CLI.dll.config
09/25/2020 07:33 PM 13,368 Confuser.CLI.pdb
09/25/2020 07:33 PM 154 Confuser.CLI.runtimeconfig.json
09/25/2020 07:33 PM 662,528 Confuser.Core.dll
09/25/2020 07:33 PM 33,280 Confuser.Core.Exports.dll
09/25/2020 07:33 PM 18,832 Confuser.Core.Exports.pdb
09/25/2020 07:33 PM 90,936 Confuser.Core.pdb
09/25/2020 07:33 PM 46,592 Confuser.DynCipher.dll
09/25/2020 07:33 PM 26,648 Confuser.DynCipher.pdb
09/25/2020 07:33 PM 39,424 Confuser.Helpers.dll
09/25/2020 07:33 PM 18,928 Confuser.Helpers.pdb
09/25/2020 07:33 PM 70,144 Confuser.Optimizations.dll
09/25/2020 07:33 PM 9,216 Confuser.Optimizations.Exports.dll
09/25/2020 07:33 PM 8,320 Confuser.Optimizations.Exports.pdb
09/25/2020 07:33 PM 29,392 Confuser.Optimizations.pdb
09/25/2020 07:33 PM 374,784 Confuser.Protections.dll
09/25/2020 07:33 PM 7,168 Confuser.Protections.Exports.dll
09/25/2020 07:33 PM 8,308 Confuser.Protections.Exports.pdb
09/25/2020 07:33 PM 68,584 Confuser.Protections.pdb
09/25/2020 07:33 PM 329,728 Confuser.Renamer.dll
09/25/2020 07:33 PM 9,216 Confuser.Renamer.Exports.dll
09/25/2020 07:33 PM 8,712 Confuser.Renamer.Exports.pdb
09/25/2020 07:33 PM 72,628 Confuser.Renamer.pdb
09/25/2020 07:33 PM 26,624 Confuser.Utilities.dll
09/25/2020 07:33 PM 13,820 Confuser.Utilities.pdb
10/29/2019 09:43 PM 1,142,784 dnlib.dll
09/27/2019 06:05 PM 243,128 Humanizer.dll
07/03/2019 10:59 PM 40,448 K4os.Compression.LZ4.dll
11/15/2019 09:36 AM 21,064 Microsoft.Bcl.AsyncInterfaces.dll
04/27/2017 06:53 PM 31,736 Microsoft.Extensions.CommandLineUtils.dll
01/01/1980 01:00 AM 21,368 Microsoft.Extensions.Configuration.Abstractions.dll
01/01/1980 01:00 AM 24,952 Microsoft.Extensions.Configuration.Binder.dll
01/01/1980 01:00 AM 27,000 Microsoft.Extensions.Configuration.dll
01/01/1980 01:00 AM 37,752 Microsoft.Extensions.DependencyInjection.Abstractions.dll
01/01/1980 01:00 AM 64,888 Microsoft.Extensions.DependencyInjection.dll
01/01/1980 01:00 AM 48,504 Microsoft.Extensions.Logging.Abstractions.dll
01/01/1980 01:00 AM 20,344 Microsoft.Extensions.Logging.Configuration.dll
01/01/1980 01:00 AM 28,024 Microsoft.Extensions.Logging.Console.dll
01/01/1980 01:00 AM 34,168 Microsoft.Extensions.Logging.dll
01/01/1980 01:00 AM 18,296 Microsoft.Extensions.Options.ConfigurationExtensions.dll
01/01/1980 01:00 AM 50,552 Microsoft.Extensions.Options.dll
01/01/1980 01:00 AM 38,264 Microsoft.Extensions.Primitives.dll
11/15/2019 09:36 AM 29,256 Microsoft.Win32.Registry.dll
11/18/2019 10:27 PM 101,960 NuGet.Frameworks.dll
09/25/2020 07:33 PM <DIR> runtimes
11/15/2019 09:37 AM 180,296 System.Collections.Immutable.dll
11/15/2019 09:54 AM 268,872 System.ComponentModel.Composition.dll
11/15/2019 09:37 AM 118,344 System.IO.Packaging.dll
11/15/2019 09:54 AM 16,760 System.Runtime.CompilerServices.Unsafe.dll
11/15/2019 09:37 AM 51,272 System.Security.AccessControl.dll
11/15/2019 09:37 AM 33,656 System.Security.Principal.Windows.dll
53 File(s) 5,029,143 bytes
3 Dir(s) 165,870,776,320 bytes free
With Windows and Linux .NET core SDK 2.2.207 x64 I get this error:
D:\confuser2.0-bin>dotnet Confuser.CLI.dll
Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'D:\confuser2.0-bin\Confuser.CLI.dll'. An attempt was made to load a program with an incorrect format.
On Linux, I get the exact same error with .NET core 2.2.207 SDK. Not sure what to do since I'm running .NET core 2.2 SDK on both platforms.