diff --git a/WHATSNEW b/WHATSNEW index 069f434cc..2f5f8b8ba 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -267,6 +267,9 @@ Other changes: * 's extraoptions can now contain multiple arguments. Bugzilla Report 23599. +* The .NET compilation tasks failed if filenames given as references + contained spaces. Bugzilla Report 27170. + Fixed bugs: ----------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java index de8aa2242..4e7ff0cb7 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetCompile.java @@ -219,7 +219,7 @@ public abstract class DotnetCompile protected String getReferencesParameter() { //bail on no references if (notEmpty(references)) { - return REFERENCE_OPTION + references; + return REFERENCE_OPTION + '\"' + references + '\"'; } else { return null; } @@ -270,8 +270,8 @@ public abstract class DotnetCompile } StringBuffer s = new StringBuffer(REFERENCE_OPTION); - s.append(refpath); - return new String(s); + s.append('\"').append(refpath).append('\"'); + return s.toString(); } @@ -903,6 +903,8 @@ public abstract class DotnetCompile if (isFileManagedBinary(file)) { if (!firstEntry) { referenceList.append(getReferenceDelimiter()); + } else { + referenceList.append('\"'); } referenceList.append(file.toString()); firstEntry = false; @@ -912,8 +914,13 @@ public abstract class DotnetCompile } } - //add it all to an argument - command.addArgument(referenceList.toString()); + // hack: This means we've added at least one reference that's + // a managed binary + if (!firstEntry) { + //add it all to an argument + command.addArgument(referenceList.toString() + '\"'); + } + return filesOutOfDate; }