3F / vsSolutionBuildEvent

🎛 Event-Catcher with variety of advanced Actions to service projects, libraries, build processes, runtime environment of the Visual Studio, MSBuild Tools, and …
Other
79 stars 22 forks source link

7z & amd64\msbuild.exe: Can not load 7-zip library or internal COM error #38

Closed 3F closed 5 years ago

3F commented 7 years ago

Found with Native scripting and GetNuTool project.

through this helper:

"packages\vsSBE.CI.MSBuild\bin\CI.MSBuild" "gnt.sln" /v:m /m:4
...
MSBuild Tools: "C:\Program Files (x86)\MSBuild\14.0\bin\amd64\\msbuild.exe"
Compact version of `../gnt.core` has been created -> `gnt.core`
Executable version of `../minified/gnt.core` has been created -> `gnt.bat`
Generate minified version in D:\prg\projects\GetNuTool\GetNuTool\embedded\\gnt.core ...
MSBuild Tools: "C:\Program Files (x86)\MSBuild\14.0\bin\amd64\\msbuild.exe"
Core 1 'D:\prg\projects\GetNuTool\GetNuTool\embedded\\../minified/gnt.core'
Core 2 'D:\prg\projects\GetNuTool\GetNuTool\embedded\\gnt.core'
Compute SHA-1 ...
Core 1 == Core 2 :: Core 1 is completely identical Core 2
18:31:10.0157 [INFO]: [Pre] finished SBE: Building
18:31:10.0788 [INFO]: Launching action 'Binaries & tools ...' :: Configuration - 'Release|x86'
18:31:10.0788 [INFO]: Use Script Mode
18:31:10.1858 [INFO]: [Post] finished SBE: Binaries & tools ...
18:31:10.1858 [INFO]: Launching action 'Zip' :: Configuration - 'Release|x86'
18:31:10.1968 [INFO]: Use Script Mode
18:31:10.2409 [ERROR]: Post-Build error: Can not load 7-zip library or internal COM error! Message: failed to load library.

so yes, the detected above msbuild.exe is x64 and IntPtr now is 8 bytes !

SevenZipSharp.dll:

if ((_modulePtr = NativeMethods.LoadLibrary(libraryFileName)) == IntPtr.Zero)
{
    throw new SevenZipLibraryException("failed to load library.");
}

TODO: to consider Conari instead of omg SevenZipSharp -_-

How to fix temporarily (for current versions):

Firstly ! the Can not load 7-zip library it can also mean any problems for path to 7z.dll

If you are using something like:

msbuild "LunaRoad.sln" /l:"packages\vsSBE.CI.MSBuild\bin\CI.MSBuild.dll" ... <args>

try this:

"packages\vsSBE.CI.MSBuild\bin\CI.MSBuild" "LunaRoad.sln" ... <args>

CI.MSBuild.bat is already stored with vssbe and contains:

msbuild %* /l:"%~dp0%cimdll%" /nologo

But if you have problem with architecture ~ Error 193 (0xC1) (SevenZipSharp lib can't manage this, but you can read here) - you need use x86 msbuild. For Visual Studio users shouldn't be problems because all versions of VS still is 32bit

Updated: temporarily you can use my msbuild-helper with -notamd64 option - https://github.com/3F/GetNuTool/blob/master/msbuild.bat

msbuild -notamd64 <args> - to select x86 instance instead of x64 if it's possible.
msbuild <args> - to select any available instance.

for example:

msbuild -notamd64 "gnt.sln" /l:"packages\vsSBE.CI.MSBuild\bin\CI.MSBuild.dll" /m:4
3F commented 7 years ago

Later I will distribute both versions x86 & x64 7z.Libs