2017-02-08 86 views
1

我想創建一個zip文件,其中包含我的Java項目的其他內容,.NET x64 EXE +其清單+ .NET DLL依賴項。它看起來像maven程序集插件會破壞EXE和DLL。事實上,如果我嘗試執行一次提取的文件,我得到「這個應用程序無法在這臺PC上運行」(無效的x64 Windows應用程序),但如果我複製原始文件,他們正常工作。Maven Assembly插件破壞exe文件dll

我試圖谷歌解決方案沒有成功。我在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> 
+0

你能分享整個異常嗎? – user3272686

+0

從事件查看器中,Windows日誌>應用程序:由於與64位版本的Windows不兼容,「程序或功能」\ ?? \

\ GetMachineId.exe無法啓動或運行,請與軟件供應商聯繫以詢問是否有64 (來源:Wow64仿真層)如果我將GetMachineId.exe替換爲原始文件並重試,我得到Microsoft .NET Framework錯誤對話框報告'... BadImageFormatException:無法加載文件或彙編'MessagingToolkit.QRCode ...' – conteit86

回答

0

發現的問題。

我實際上也使用maven-resources-plugin${launcher.dir}進行過濾。

從過濾中排除二進制文件解決了問題。