尝试将应用程序移植到 docker nanoserver 容器。 运行 exe 失败,退出代码为 -1073741515(缺少依赖项)

Trying to port application to docker nanoserver container. Running exe fails with exit code -1073741515 (Dependency missing)

我目前正在尝试将我的图像优化器应用程序移植到 NanoServer docker 图像。我的图像优化器使用的工具之一是 truepng.exe。 (可以在这里下载:http://x128.ho.ua/clicks/clicks.php?uri=TruePNG_0625.zip

我只是创建了一个 nanoserver 容器并安装了一个包含 truepng.exe:

的文件夹
docker run --rm -it -v C:\data:C:\data mcr.microsoft.com/windows/nanoserver:2004-amd64

当我现在 运行 truepng.exe 我希望一些关于命令行参数丢失的输出:

C:\MyLocalWindowsMachine>truepng
TruePNG 0.6.2.5 : PNG Optimizer
by x128 (2010-2017)
x128@ua.fm

...

然而,当我从 nanoserver docker 容器内部调用它时,我基本上看不到任何输出:

C:\data>truepng

C:\data>echo %ERRORLEVEL%
-1073741515

如上所示,退出代码设置为 -1073741515。根据 this,这通常意味着缺少依赖项。

然后我下载了https://github.com/lucasg/Dependencies看truepng的依赖:

它似乎对 5 个 DLL 有一些依赖。查找这些我发现显然有一个叫做 'Reverse Forwarders' 的东西:https://cloudblogs.microsoft.com/windowsserver/2015/11/16/moving-to-nano-server-the-new-deployment-option-in-windows-server-2016/

根据以下 post 尽管它们应该已经包含在 nanoserver 中:https://social.technet.microsoft.com/Forums/en-US/5b36a6d3-84c9-4940-8b7a-9e2a38468291/reverse-forwarders-package-in-tp5?forum=NanoServer

在所有这些调查之后,我也一直在尝试将 DLL 从我的本地机器 (system32) 手动复制到 docker 机器但没有任何成功(它只是不断破坏其他东西,比如副本命令要求我重新创建容器)。除此之外,我还从 SysWOW64 复制了文件,但这也没有帮助。

我目前对如何继续进行感到非常困惑,因为我什至不确定该工具是否缺少依赖项或者是否正在发生其他事情。有没有办法在工具启动后调查缺少哪些 DLL?

亲切的问候,

德维兹

编辑 1:@CherryDT 的想法 我尝试了 运行ning gflags (https://social.msdn.microsoft.com/Forums/en-US/f004a7e5-9024-4555-9ada-e692fbc3160d/how-to-start-quotloader-snapsquot?forum=vcgeneral),它给出了以下输出:

C:\data>"C:\data\gflags.exe" /i TruePNG.exe +sls
Current Registry Settings for TruePNG.exe executable are: 00000000

在此之后我尝试了 运行ning Dbgview.exe,但是这并没有导致写入日志文件:

C:\data>"C:\data\DebugView\Dbgview.exe" /v /l debugview-log.txt /g /n

C:\data>

我也重新启动了TruePNG.exe,但是还是没有写入日志文件。

我尝试使用 dotnet 核心应用程序查询事件日志,但这导致了以下异常:

Unhandled exception. System.InvalidOperationException: Cannot open log Application on computer '.'. This function is not supported on this system.
   at System.Diagnostics.EventLogInternal.OpenForRead(String currentMachineName)
   at System.Diagnostics.EventLogInternal.GetEntryAtNoThrow(Int32 index)
   at System.Diagnostics.EventLogEntryCollection.GetEntryAtNoThrow(Int32 index)
   at System.Diagnostics.EventLogEntryCollection.EntriesEnumerator.MoveNext()
   at EventLogReaderTest.ConsoleApp.Program.Main(String[] args) in C:\data\EventLogReaderTest.ConsoleApp\Program.cs:line 22

Windows Nano Server 很小而且只有 supports 64-bit applications, tools, and agents. The missing dependency in this case is the entire x86 emulation layer (WoW64),因为 TruePNG 是一个 32 位应用程序。

Windows Server Core 包含 Nano Server 缺少的 WoW64 和其他组件。请改用 Windows Server Core image

示例命令:

docker run --rm -it -v C:\Temp:C:\Temp mcr.microsoft.com/windows/servercore:2004 C:\Temp\TruePNG.exe

产生预期的输出:

TruePNG 0.6.2.5 : PNG Optimizer
by x128 (2010-2017)
x128@ua.fm

TruePNG {options} files

options:
/f#     PNG delta filters 0=None, 1=Sub, 2=Up, 3=Average, 4=Paeth, 5=Mixed
/fe     PNG extra filters, overrides /f switch
/i#     PNG interlace method 0=None, 1=Adam7 (default input)
/g#     PNG gamma 0=Remove, 1=Apply & Remove, 2=Keep (default)
[...]