【发布时间】:2017-02-08 17:09:11
【问题描述】:
我正在尝试创建一个 zip 文件,其中包含我的 Java 项目的其他内容,一个 .NET x64 EXE + 它的清单 + 一个 .NET DLL 依赖项。看起来 maven 程序集插件损坏了 EXE 和 DLL。事实上,如果我在提取后尝试执行文件,我会得到“此应用程序无法在这台 PC 上运行”(无效的 x64 Windows 应用程序),但如果我复制原始文件,它们可以正常工作。
我试图用谷歌搜索一个没有成功的解决方案。我在 Maven 文件中遗漏了什么吗?
pom.xml 中的插件声明是:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/windows.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<finalName>${bundle.name}</finalName>
</configuration>
</execution>
</executions>
</plugin>
而windows.xml 的内容是:
<?xml version="1.0"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>windows</id>
<formats>
<format>zip</format>
</formats>
<files>
<file>
<source>${launcher.dir}/GetMachineId.exe</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>GetMachineId.exe</destName>
</file>
<file>
<source>${launcher.dir}/GetMachineId.exe.config</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>GetMachineId.exe.config</destName>
</file>
<file>
<source>${launcher.dir}/MessagingToolkit.QRCode.dll</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>MessagingToolkit.QRCode.dll</destName>
</file>
</files>
</assembly>
【问题讨论】:
-
你能分享整个异常吗?
-
来自事件查看器、Windows 日志 > 应用程序:
The program or feature "\??\<dir>\GetMachineId.exe cannot start or run due to incompatibility with 64-bit versions of Windows. Please contact the software vendor to ask if a 64-bit Windows compatible version is available.(来源:Wow64 仿真层)。如果我用原始文件替换 GetMachineId.exe 并重试,我会收到 Microsoft .NET Framework 错误对话框报告...BadImageFormatException: Could not load file or assembly 'MessagingToolkit.QRCode...
标签: dll exe maven-assembly-plugin