Maven Assembly Plugins corrupts exe dll
I'm trying to create a zip file containing, among other stuff of my Java project, a .NET x64 EXE + its manifest + a .NET DLL dependency. It looks like maven assembly plugin corrupts the EXE and the DLL. In fact if I try to execute the file once extracted I get "This app can't run on this PC" (invalid x64 windows application), but if I copy the original files they work normally.
I've tried to google for a solution without success. Am I missing something in maven files?
Plugin declaration in pom.xml
is:
<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>
while windows.xml
content is:
<?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>
dll exe maven-assembly-plugin
add a comment |
I'm trying to create a zip file containing, among other stuff of my Java project, a .NET x64 EXE + its manifest + a .NET DLL dependency. It looks like maven assembly plugin corrupts the EXE and the DLL. In fact if I try to execute the file once extracted I get "This app can't run on this PC" (invalid x64 windows application), but if I copy the original files they work normally.
I've tried to google for a solution without success. Am I missing something in maven files?
Plugin declaration in pom.xml
is:
<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>
while windows.xml
content is:
<?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>
dll exe maven-assembly-plugin
Can you share the entire exception?
– user3272686
Feb 8 '17 at 17:15
From Event Viewer, Windows Logs > Application: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.
(source: Wow64 Emulation Layer). If I replace GetMachineId.exe with the original file and retry, I get Microsoft .NET Framework error dialog reporting...BadImageFormatException: Could not load file or assembly 'MessagingToolkit.QRCode...
– conteit86
Feb 9 '17 at 7:46
add a comment |
I'm trying to create a zip file containing, among other stuff of my Java project, a .NET x64 EXE + its manifest + a .NET DLL dependency. It looks like maven assembly plugin corrupts the EXE and the DLL. In fact if I try to execute the file once extracted I get "This app can't run on this PC" (invalid x64 windows application), but if I copy the original files they work normally.
I've tried to google for a solution without success. Am I missing something in maven files?
Plugin declaration in pom.xml
is:
<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>
while windows.xml
content is:
<?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>
dll exe maven-assembly-plugin
I'm trying to create a zip file containing, among other stuff of my Java project, a .NET x64 EXE + its manifest + a .NET DLL dependency. It looks like maven assembly plugin corrupts the EXE and the DLL. In fact if I try to execute the file once extracted I get "This app can't run on this PC" (invalid x64 windows application), but if I copy the original files they work normally.
I've tried to google for a solution without success. Am I missing something in maven files?
Plugin declaration in pom.xml
is:
<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>
while windows.xml
content is:
<?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>
dll exe maven-assembly-plugin
dll exe maven-assembly-plugin
asked Feb 8 '17 at 17:09
conteit86conteit86
9613
9613
Can you share the entire exception?
– user3272686
Feb 8 '17 at 17:15
From Event Viewer, Windows Logs > Application: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.
(source: Wow64 Emulation Layer). If I replace GetMachineId.exe with the original file and retry, I get Microsoft .NET Framework error dialog reporting...BadImageFormatException: Could not load file or assembly 'MessagingToolkit.QRCode...
– conteit86
Feb 9 '17 at 7:46
add a comment |
Can you share the entire exception?
– user3272686
Feb 8 '17 at 17:15
From Event Viewer, Windows Logs > Application: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.
(source: Wow64 Emulation Layer). If I replace GetMachineId.exe with the original file and retry, I get Microsoft .NET Framework error dialog reporting...BadImageFormatException: Could not load file or assembly 'MessagingToolkit.QRCode...
– conteit86
Feb 9 '17 at 7:46
Can you share the entire exception?
– user3272686
Feb 8 '17 at 17:15
Can you share the entire exception?
– user3272686
Feb 8 '17 at 17:15
From Event Viewer, Windows Logs > Application:
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.
(source: Wow64 Emulation Layer). If I replace GetMachineId.exe with the original file and retry, I get Microsoft .NET Framework error dialog reporting ...BadImageFormatException: Could not load file or assembly 'MessagingToolkit.QRCode...
– conteit86
Feb 9 '17 at 7:46
From Event Viewer, Windows Logs > Application:
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.
(source: Wow64 Emulation Layer). If I replace GetMachineId.exe with the original file and retry, I get Microsoft .NET Framework error dialog reporting ...BadImageFormatException: Could not load file or assembly 'MessagingToolkit.QRCode...
– conteit86
Feb 9 '17 at 7:46
add a comment |
1 Answer
1
active
oldest
votes
Found the issue.
I was actually using also maven-resources-plugin
on ${launcher.dir}
with filtering.
Excluding binary files from filtering solved the problem.
UPDATE:
In my pom.xml the maven-resources-plugin
was configured like in the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>filtering-launcher-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${launcher.dir}</outputDirectory>
<resources>
<resource>
<directory>src/main/launcher</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
With src/main/launcher
erroneously containing both text file (that actually required filtering) and binary ones (GetMachineId.exe
, GetMachineId.exe.config
, MessagingToolkit.QRCore.dll
).
In order to solve the problem I've moved those binaries in a different folder (utils
) and modified the assembly file like this:
<?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>utils/GetMachineId.exe</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>GetMachineId.exe</destName>
</file>
<file>
<source>utils/GetMachineId.exe.config</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>GetMachineId.exe.config</destName>
</file>
<file>
<source>utils/MessagingToolkit.QRCode.dll</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>MessagingToolkit.QRCode.dll</destName>
</file>
<file>
<source>${launcher.dir}/config.xml</source>
<outputDirectory>bin</outputDirectory>
<destName>config.xml</destName>
</file>
</files>
</assembly>
This way maven-resources-plugin
does not process with filtering the binaries, so they do not get corrupted. It looks like the filtering process treats always the files like they are text ones, so it modifies binaries in such a way that prevents their execution.
Another, more recent, strategy could be this one: https://maven.apache.org/plugins/maven-resources-plugin/examples/binaries-filtering.html
Same problem here. I would have appreciated a short sentence on how to exclude binary files from filtering. But a search machine will tell me soon.
– Martin
Nov 7 '18 at 7:16
@Martin: I hope the update will help you
– conteit86
Nov 27 '18 at 16:37
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42119425%2fmaven-assembly-plugins-corrupts-exe-dll%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Found the issue.
I was actually using also maven-resources-plugin
on ${launcher.dir}
with filtering.
Excluding binary files from filtering solved the problem.
UPDATE:
In my pom.xml the maven-resources-plugin
was configured like in the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>filtering-launcher-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${launcher.dir}</outputDirectory>
<resources>
<resource>
<directory>src/main/launcher</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
With src/main/launcher
erroneously containing both text file (that actually required filtering) and binary ones (GetMachineId.exe
, GetMachineId.exe.config
, MessagingToolkit.QRCore.dll
).
In order to solve the problem I've moved those binaries in a different folder (utils
) and modified the assembly file like this:
<?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>utils/GetMachineId.exe</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>GetMachineId.exe</destName>
</file>
<file>
<source>utils/GetMachineId.exe.config</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>GetMachineId.exe.config</destName>
</file>
<file>
<source>utils/MessagingToolkit.QRCode.dll</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>MessagingToolkit.QRCode.dll</destName>
</file>
<file>
<source>${launcher.dir}/config.xml</source>
<outputDirectory>bin</outputDirectory>
<destName>config.xml</destName>
</file>
</files>
</assembly>
This way maven-resources-plugin
does not process with filtering the binaries, so they do not get corrupted. It looks like the filtering process treats always the files like they are text ones, so it modifies binaries in such a way that prevents their execution.
Another, more recent, strategy could be this one: https://maven.apache.org/plugins/maven-resources-plugin/examples/binaries-filtering.html
Same problem here. I would have appreciated a short sentence on how to exclude binary files from filtering. But a search machine will tell me soon.
– Martin
Nov 7 '18 at 7:16
@Martin: I hope the update will help you
– conteit86
Nov 27 '18 at 16:37
add a comment |
Found the issue.
I was actually using also maven-resources-plugin
on ${launcher.dir}
with filtering.
Excluding binary files from filtering solved the problem.
UPDATE:
In my pom.xml the maven-resources-plugin
was configured like in the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>filtering-launcher-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${launcher.dir}</outputDirectory>
<resources>
<resource>
<directory>src/main/launcher</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
With src/main/launcher
erroneously containing both text file (that actually required filtering) and binary ones (GetMachineId.exe
, GetMachineId.exe.config
, MessagingToolkit.QRCore.dll
).
In order to solve the problem I've moved those binaries in a different folder (utils
) and modified the assembly file like this:
<?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>utils/GetMachineId.exe</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>GetMachineId.exe</destName>
</file>
<file>
<source>utils/GetMachineId.exe.config</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>GetMachineId.exe.config</destName>
</file>
<file>
<source>utils/MessagingToolkit.QRCode.dll</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>MessagingToolkit.QRCode.dll</destName>
</file>
<file>
<source>${launcher.dir}/config.xml</source>
<outputDirectory>bin</outputDirectory>
<destName>config.xml</destName>
</file>
</files>
</assembly>
This way maven-resources-plugin
does not process with filtering the binaries, so they do not get corrupted. It looks like the filtering process treats always the files like they are text ones, so it modifies binaries in such a way that prevents their execution.
Another, more recent, strategy could be this one: https://maven.apache.org/plugins/maven-resources-plugin/examples/binaries-filtering.html
Same problem here. I would have appreciated a short sentence on how to exclude binary files from filtering. But a search machine will tell me soon.
– Martin
Nov 7 '18 at 7:16
@Martin: I hope the update will help you
– conteit86
Nov 27 '18 at 16:37
add a comment |
Found the issue.
I was actually using also maven-resources-plugin
on ${launcher.dir}
with filtering.
Excluding binary files from filtering solved the problem.
UPDATE:
In my pom.xml the maven-resources-plugin
was configured like in the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>filtering-launcher-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${launcher.dir}</outputDirectory>
<resources>
<resource>
<directory>src/main/launcher</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
With src/main/launcher
erroneously containing both text file (that actually required filtering) and binary ones (GetMachineId.exe
, GetMachineId.exe.config
, MessagingToolkit.QRCore.dll
).
In order to solve the problem I've moved those binaries in a different folder (utils
) and modified the assembly file like this:
<?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>utils/GetMachineId.exe</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>GetMachineId.exe</destName>
</file>
<file>
<source>utils/GetMachineId.exe.config</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>GetMachineId.exe.config</destName>
</file>
<file>
<source>utils/MessagingToolkit.QRCode.dll</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>MessagingToolkit.QRCode.dll</destName>
</file>
<file>
<source>${launcher.dir}/config.xml</source>
<outputDirectory>bin</outputDirectory>
<destName>config.xml</destName>
</file>
</files>
</assembly>
This way maven-resources-plugin
does not process with filtering the binaries, so they do not get corrupted. It looks like the filtering process treats always the files like they are text ones, so it modifies binaries in such a way that prevents their execution.
Another, more recent, strategy could be this one: https://maven.apache.org/plugins/maven-resources-plugin/examples/binaries-filtering.html
Found the issue.
I was actually using also maven-resources-plugin
on ${launcher.dir}
with filtering.
Excluding binary files from filtering solved the problem.
UPDATE:
In my pom.xml the maven-resources-plugin
was configured like in the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>filtering-launcher-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${launcher.dir}</outputDirectory>
<resources>
<resource>
<directory>src/main/launcher</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
With src/main/launcher
erroneously containing both text file (that actually required filtering) and binary ones (GetMachineId.exe
, GetMachineId.exe.config
, MessagingToolkit.QRCore.dll
).
In order to solve the problem I've moved those binaries in a different folder (utils
) and modified the assembly file like this:
<?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>utils/GetMachineId.exe</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>GetMachineId.exe</destName>
</file>
<file>
<source>utils/GetMachineId.exe.config</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>GetMachineId.exe.config</destName>
</file>
<file>
<source>utils/MessagingToolkit.QRCode.dll</source>
<outputDirectory>bin/utils</outputDirectory>
<destName>MessagingToolkit.QRCode.dll</destName>
</file>
<file>
<source>${launcher.dir}/config.xml</source>
<outputDirectory>bin</outputDirectory>
<destName>config.xml</destName>
</file>
</files>
</assembly>
This way maven-resources-plugin
does not process with filtering the binaries, so they do not get corrupted. It looks like the filtering process treats always the files like they are text ones, so it modifies binaries in such a way that prevents their execution.
Another, more recent, strategy could be this one: https://maven.apache.org/plugins/maven-resources-plugin/examples/binaries-filtering.html
edited Nov 27 '18 at 16:36
answered Feb 10 '17 at 14:31
conteit86conteit86
9613
9613
Same problem here. I would have appreciated a short sentence on how to exclude binary files from filtering. But a search machine will tell me soon.
– Martin
Nov 7 '18 at 7:16
@Martin: I hope the update will help you
– conteit86
Nov 27 '18 at 16:37
add a comment |
Same problem here. I would have appreciated a short sentence on how to exclude binary files from filtering. But a search machine will tell me soon.
– Martin
Nov 7 '18 at 7:16
@Martin: I hope the update will help you
– conteit86
Nov 27 '18 at 16:37
Same problem here. I would have appreciated a short sentence on how to exclude binary files from filtering. But a search machine will tell me soon.
– Martin
Nov 7 '18 at 7:16
Same problem here. I would have appreciated a short sentence on how to exclude binary files from filtering. But a search machine will tell me soon.
– Martin
Nov 7 '18 at 7:16
@Martin: I hope the update will help you
– conteit86
Nov 27 '18 at 16:37
@Martin: I hope the update will help you
– conteit86
Nov 27 '18 at 16:37
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42119425%2fmaven-assembly-plugins-corrupts-exe-dll%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you share the entire exception?
– user3272686
Feb 8 '17 at 17:15
From Event Viewer, Windows Logs > Application:
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.
(source: Wow64 Emulation Layer). If I replace GetMachineId.exe with the original file and retry, I get Microsoft .NET Framework error dialog reporting...BadImageFormatException: Could not load file or assembly 'MessagingToolkit.QRCode...
– conteit86
Feb 9 '17 at 7:46