malware-dev / MDK-SE

Malware's Development Kit for SE
MIT License
1.02k stars 123 forks source link

[MDK2] Unable to load DLL files even with a fresh ingame script project on build. #311

Closed DragonIndustries23 closed 8 months ago

DragonIndustries23 commented 8 months ago

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:

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.

malware-dev commented 8 months ago

Comment out the old MDK1 bootstrapper to avoid build errors. That should not be necessary, indicating that you have a preexisting problem.

malware-dev commented 8 months ago

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

DragonIndustries23 commented 8 months ago

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.

DragonIndustries23 commented 8 months ago

Had to re-install VS and re-install all of my .NET packages, worked afterwards.