/noconfig causes an error if used inside a response file. PR 34992. Submitted by Chris Nagy
git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/dotnet/trunk@677883 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/changes.xml b/changes.xml
index bec09cf..21ebd03 100644
--- a/changes.xml
+++ b/changes.xml
@@ -38,6 +38,9 @@
</properties>
<release version="SVN trunk" date="unpublished">
+ <action type="fix" issue="34992">
+ The /noconfig argument must be used outside of a response file.
+ </action>
<action type="fix">
CSC of .NET 3.5 doesn't support the /incremental argument
anymore, only set /incremental+, but never /incremental-.
diff --git a/contributors.xml b/contributors.xml
index fbada21..a8e5526 100644
--- a/contributors.xml
+++ b/contributors.xml
@@ -43,6 +43,10 @@
<last>Watson</last>
</name>
<name>
+ <first>Chris</first>
+ <last>Nagy</last>
+ </name>
+ <name>
<first>Conor</first>
<last>MacNeill</last>
</name>
diff --git a/src/main/org/apache/ant/dotnet/NetCommand.java b/src/main/org/apache/ant/dotnet/NetCommand.java
index eaec57c..4258958 100644
--- a/src/main/org/apache/ant/dotnet/NetCommand.java
+++ b/src/main/org/apache/ant/dotnet/NetCommand.java
@@ -32,7 +32,9 @@
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.BufferedOutputStream;
+import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.List;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -51,7 +53,6 @@
* setting the path to point to the dotnet bin directory; in which case the
* shared code should go in here.
*
- *@version 0.5
*/
public class NetCommand {
@@ -115,6 +116,13 @@
private int automaticResponseFileThreshold = 64;
/**
+ * List of command line arguments that must appear on the command
+ * line and must not go into a response file.
+ * @since .NET Antlib 1.1
+ */
+ private List argsOnCommandLine = new ArrayList();
+
+ /**
* constructor
*
*@param title (for logging/errors)
@@ -194,24 +202,45 @@
* add an argument to a command line; do nothing if the arg is null or
* empty string
*
- *@param argument The feature to be added to the Argument attribute
+ * <p>The given argument may be added to a response file.</p>
+ *
+ * @param argument The feature to be added to the Argument attribute
*/
public void addArgument(String argument) {
+ addArgument(argument, true);
+ }
+
+ /**
+ * add an argument to a command line; do nothing if the arg is
+ * null or empty string
+ *
+ * @param argument The feature to be added to the Argument attribute
+ * @param mayBeInResponseFile whether the argument is allowed
+ * inside a response file.
+ *
+ * @since .NET Antlib 1.1
+ */
+ public void addArgument(String argument, boolean mayBeInResponseFile) {
if (argument != null && argument.length() != 0) {
commandLine.createArgument().setValue(argument);
+ if (!mayBeInResponseFile) {
+ argsOnCommandLine.add(argument);
+ }
}
}
/**
- * add an argument to a command line; do nothing if the arg is null or
- * empty string
+ * Add multiple arguments to a command line; do nothing for args
+ * that are is null or empty strings
*
- *@param arguments The features to be added to the Argument attribute
+ * <p>The given arguments may be added to a response file.</p>
+ *
+ * @param arguments The features to be added to the Argument attribute
*/
public void addArguments(String[] arguments) {
if (arguments != null && arguments.length != 0) {
for (int i = 0; i < arguments.length; i++) {
- addArgument(arguments[i]);
+ addArgument(arguments[i], true);
}
}
}
@@ -220,12 +249,14 @@
* concatenate two strings together and add them as a single argument,
* but only if argument2 is non-null and non-zero length
*
+ * <p>The resulting argument may be added to a response file.</p>
+ *
*@param argument1 The first argument
*@param argument2 The second argument
*/
public void addArgument(String argument1, String argument2) {
if (argument2 != null && argument2.length() != 0) {
- commandLine.createArgument().setValue(argument1 + argument2);
+ addArgument(argument1 + argument2, true);
}
}
@@ -351,6 +382,9 @@
PrintWriter out = new PrintWriter(new BufferedOutputStream(fos));
//start at 1 because element 0 is the executable name
for (int i = 1; i < commands.length; ++i) {
+ if (argsOnCommandLine.contains(commands[i])) {
+ continue;
+ }
if (commands[i].indexOf(" ") > -1) {
String q = commands[i].indexOf("\"") > -1 ? "'" : "\"";
out.print(q);
@@ -366,9 +400,14 @@
throw new BuildException("saving command stream to " + temporaryCommandFile, ex);
}
- String newCommandLine[] = new String[2];
+ String newCommandLine[] = new String[2 + argsOnCommandLine.size()];
newCommandLine[0] = commands[0];
- newCommandLine[1] = "@" + temporaryCommandFile.getAbsolutePath();
+ if (argsOnCommandLine.size() > 0) {
+ System.arraycopy(argsOnCommandLine.toArray(), 0,
+ newCommandLine, 1, argsOnCommandLine.size());
+ }
+ newCommandLine[newCommandLine.length - 1] =
+ "@" + temporaryCommandFile.getAbsolutePath();
logVerbose(Commandline.describeCommand(newCommandLine));
executable.setCommandline(newCommandLine);
}
diff --git a/src/main/org/apache/ant/dotnet/compile/CSharp.java b/src/main/org/apache/ant/dotnet/compile/CSharp.java
index 413e34b..86d2584 100644
--- a/src/main/org/apache/ant/dotnet/compile/CSharp.java
+++ b/src/main/org/apache/ant/dotnet/compile/CSharp.java
@@ -362,7 +362,7 @@
if (getIncremental()) {
command.addArgument(getIncrementalParameter());
}
- command.addArgument(getNoConfigParameter());
+ command.addArgument(getNoConfigParameter(), false);
command.addArgument(getUnsafeParameter());
}
diff --git a/src/tests/antunit/dotnetexec-test.xml b/src/tests/antunit/dotnetexec-test.xml
index 900d5cb..f2514f0 100755
--- a/src/tests/antunit/dotnetexec-test.xml
+++ b/src/tests/antunit/dotnetexec-test.xml
@@ -78,5 +78,13 @@
<dn:dotnetexec executable="${testCSC.exe}" failonerror="true" />
</target>
+ <target name="testCSCNoConfig" depends="validate_csc">
+ <dn:csc noconfig="true" useresponsefile="true"
+ destFile="${testCSC.exe}"
+ targetType="exe">
+ <src dir="${src.dir}" includes="ex*.cs"/>
+ </dn:csc>
+ <au:assertLogContains text="/noconfig" level="verbose"/>
+ </target>
</project>