[MDK2] Unable to load DLL files even with a fresh ingame script project on build.
DragonIndustries23 opened this issue · 4 comments
Here is the error to be exact:
1>------ Build started: Project: SE Deploy Test Script, Configuration: Debug x64 ------
1> Successfully determined the binary path of Space Engineers: A:\SteamLibrary\SteamApps\common\SpaceEngineers\Bin64
1> Loading Space Engineers assemblies from A:\SteamLibrary\SteamApps\common\SpaceEngineers\Bin64
1> SE Deploy Test Script -> C:\Users\drago\source\repos\SE Deploy Test Script\bin\SE Deploy Test Script.exe
1> Unhandled exception. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
1> Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Format of the executable (.exe) or library (.dll) is invalid.
1> Could not load file or assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Format of the executable (.exe) or library (.dll) is invalid.
1> Could not load file or assembly 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'. Format of the executable (.exe) or library (.dll) is invalid.
1> Could not load file or assembly 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'. Format of the executable (.exe) or library (.dll) is invalid.
1> Could not load file or assembly 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'. Format of the executable (.exe) or library (.dll) is invalid.
1> Could not load file or assembly 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'. Format of the executable (.exe) or library (.dll) is invalid.
1> Could not load file or assembly 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'. Format of the executable (.exe) or library (.dll) is invalid.
1> at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
1> at System.Composition.Hosting.ContainerConfiguration.<>c.<WithAssemblies>b__16_0(Assembly a)
1> at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
1> at System.Composition.TypedParts.TypedPartExportDescriptorProvider..ctor(IEnumerable`1 types, AttributedModelProvider attributeContext)
1> at System.Composition.Hosting.ContainerConfiguration.CreateContainer()
1> at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create(IEnumerable`1 assemblies)
1> at Microsoft.CodeAnalysis.Host.Mef.MSBuildMefHostServices.get_DefaultServices()
1> at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create(IDictionary`2 properties)
1> at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create()
1> at Mdk.CommandLine.IngameScript.ScriptPacker.PackAsync(PackOptions options, IConsole console)
1> at Mdk.CommandLine.Commands.PackScript.PackScriptCommand.ExecuteAsync(List`1 arguments, IConsole console)
1> at Mdk.CommandLine.Program.Main(String[] args)
1> at Mdk.CommandLine.Program.<Main>(String[] args)
1> System.BadImageFormatException: Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Format of the executable (.exe) or library (.dll) is invalid.
1> File name: 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.BadImageFormatException: Could not load file or assembly 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.Framework.dll'. Format of the executable (.exe) or library (.dll) is invalid.
1> File name: 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.Framework.dll'
1> at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
1> at System.Reflection.Assembly.LoadFrom(String assemblyFile)
1> at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass19_0.<RegisterMSBuildPath>g__TryLoadAssembly|3(AssemblyName assemblyName)
1> at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass19_0.<RegisterMSBuildPath>b__2(AssemblyLoadContext _, AssemblyName assemblyName)
1> at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
1> at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
1> at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
1> System.BadImageFormatException: Could not load file or assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Format of the executable (.exe) or library (.dll) is invalid.
1> File name: 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.BadImageFormatException: Could not load file or assembly 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'. Format of the executable (.exe) or library (.dll) is invalid.
1> File name: 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'
1> at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
1> at System.Reflection.Assembly.LoadFrom(String assemblyFile)
1> at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass19_0.<RegisterMSBuildPath>g__TryLoadAssembly|3(AssemblyName assemblyName)
1> at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass19_0.<RegisterMSBuildPath>b__2(AssemblyLoadContext _, AssemblyName assemblyName)
1> at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
1> at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
1> at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
1> System.BadImageFormatException: Could not load file or assembly 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'. Format of the executable (.exe) or library (.dll) is invalid.
1> File name: 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'
1> System.BadImageFormatException: Could not load file or assembly 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'. Format of the executable (.exe) or library (.dll) is invalid.
1> File name: 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'
1> System.BadImageFormatException: Could not load file or assembly 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'. Format of the executable (.exe) or library (.dll) is invalid.
1> File name: 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'
1> System.BadImageFormatException: Could not load file or assembly 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'. Format of the executable (.exe) or library (.dll) is invalid.
1> File name: 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'
1> System.BadImageFormatException: Could not load file or assembly 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'. Format of the executable (.exe) or library (.dll) is invalid.
1> File name: 'C:\Program Files (x86)\dotnet\sdk\8.0.201\Microsoft.Build.dll'
1>C:\Users\drago\source\repos\SE Deploy Test Script\packages\Mal.Mdk2.PbPackager.2.0.0-alpha031\build\Mal.Mdk2.PbPackager.props(31,9): error MSB3073: The command ""C:\Users\drago\source\repos\SE Deploy Test Script\packages\Mal.Mdk2.PbPackager.2.0.0-alpha031\build\..\tools\mdk.exe" pack-script "C:\Users\drago\source\repos\SE Deploy Test Script\SE Deploy Test Script.csproj" -minifier none -output "auto" -interactive " exited with code -532462766.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
To reproduce:
- Make a brand new Ingame Script the old MDK1 way.
- Comment out the old MDK1 bootstrapper to avoid build errors.
- Install the MDK2 PbPackager since I am using 17.9.2 and add the extra config stuff. (Tried to build here, same error)
- Manually go into the NuGet package manager and install MS.Build and MS.Build.Framework (latest version 17.9.5, in DLL it is the 15.1.0.0 version which I have checked with ILSpy but error persists anyway)
- Try to build again, got the same error. I did go into said locations inside the error but the files literally are there with the correct extension and all.
To note the first time I tried it prompted me to install .NET 8 SDK which I did afterwards.
I may be doing things wrong however I can't really tell, I will try to respond ASAP if this issue gets replied to.
Comment out the old MDK1 bootstrapper to avoid build errors.
That should not be necessary, indicating that you have a preexisting problem.
Manually go into the NuGet package manager and install MS.Build and MS.Build.Framework (latest version 17.9.5, in DLL it is the 15.1.0.0 version which I have checked with ILSpy but error persists anyway)
Don't do that.
MDK uses a system to find the existing msbuild on your system. MDK2 runs on .net 8. Installing .NET 8 SDK will likely have given you the appropriate msbuild.
I thought it would run just fine with whatever MSBuild you have installed... as long as it's compatible with the ingame script project
Manually go into the NuGet package manager and install MS.Build and MS.Build.Framework (latest version 17.9.5, in DLL it is the 15.1.0.0 version which I have checked with ILSpy but error persists anyway)
Don't do that.MDK uses a system to find the existing msbuild on your system. MDK2 runs on .net 8. Installing .NET 8 SDK will likely have given you the appropriate msbuild.
Note: solved the bootstrapper issue, that was my bad.
Actual reply: Just made a fresh MDK1 Ingame script like usual, added only the MDK2 Pb Packager and touched nothing else, still have the SDK for .NET 8 and same issue.
To note I am up for grabs on discord if you got time for it so that we don't explode the comment section with replies.
Had to re-install VS and re-install all of my .NET packages, worked afterwards.