fix msbuild task

git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/dotnet/trunk@357118 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/docs/index.html b/docs/index.html
index 7ab70bc..66272d8 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -15,16 +15,15 @@
 
     <h2>Requirements</h2>
 
-    <p>The current version requires Ant 1.6.2 or later and may even
-    work better for a CVS build of Ant created from CVS HEAD.</p>
+    <p>The current version requires Ant 1.7 or at least a version
+    built from svn trunk no earlier than 2005-12-16.</p>
 
     <h2>Where is it?</h2>
 
-    <p>The source code for the library currently lives in the
-    developer sandbox in Ant's SVN - <a
-    href="http://svn.apache.org/viewcvs.cgi/ant/sandbox/antlibs/dotnet/trunk/">http://svn.apache.org/viewcvs.cgi/ant/sandbox/antlibs/dotnet/trunk/</a>
+    <p>The source code for the library lives in Ant's SVN - <a
+    href="http://svn.apache.org/repos/asf/ant/antlibs/dotnet/trunk/">http://svn.apache.org/repos/asf/ant/antlibs/dotnet/trunk/</a>
     A binary can be found at <a
-    href="http://people.apache.org/~bodewig/dotnet/dotnet.jar">http://cvs.apache.org/~bodewig/dotnet/dotnet.jar</a>.
+    href="http://people.apache.org/~bodewig/dotnet/ant-dotnet.jar">http://cvs.apache.org/~bodewig/dotnet/ant-dotnet.jar</a>.
     A zip file containing the docs is also <a
     href="http://people.apache.org/~bodewig/dotnet/docs.zip">available</a>.</p>
 
@@ -32,15 +31,14 @@
 
     <h2>Feedback</h2>
 
-    <p>Right now direct any feedback either directly to <a
-    href="mailto:bodewig@apache.org">me</a> or the <a
+    <p>Please direct any feedback to the <a
     href="http://ant.apache.org/mail.html#Developer List">Ant
     developer list</a>.
 
     <h2>Installation</h2>
 
     <p>If you are building this from sources, run the antlib target
-    and you'll get a file <code>dotnet.jar</code>.  If you've
+    and you'll get a file <code>ant-dotnet.jar</code>.  If you've
     downloaded <code>dotnet.jar</code>, you are already ready.</p>
 
     <p>There are several ways to use the tasks:</p>
@@ -51,7 +49,7 @@
           &lt;taskdef 
             resource="org/apache/ant/dotnet/antlib.xml"&gt;
             &lt;classpath&gt;
-              &lt;pathelement location="YOUR-PATH-TO/dotnet.jar"/&gt;
+              &lt;pathelement location="YOUR-PATH-TO/ant-dotnet.jar"/&gt;
             &lt;/classpath&gt;
           &lt;/taskdef&gt;
         </pre>
@@ -68,7 +66,7 @@
             uri="antlib:org.apache.ant.dotnet"
             resource="org/apache/ant/dotnet/antlib.xml"&gt;
             &lt;classpath&gt;
-              &lt;pathelement location="YOUR-PATH-TO/dotnet.jar"/&gt;
+              &lt;pathelement location="YOUR-PATH-TO/ant-dotnet.jar"/&gt;
             &lt;/classpath&gt;
           &lt;/taskdef&gt;
         </pre>
@@ -97,7 +95,7 @@
         or a variation thereof.
       </li>
 
-      <li>Using Ant's autodiscovery.  Place <code>dotnet.jar</code>
+      <li>Using Ant's autodiscovery.  Place <code>ant-dotnet.jar</code>
       into a directory and use <code>ant -lib
       DIR-CONTAINING-THE-JAR</code> or copy it into
       <code>ANT_HOME/lib</code> - and then in your build file, simply
@@ -127,7 +125,7 @@
       tool.</li>
 
       <li><a href="msbuild.html">msbuild</a> - execute the MSBuild build
-      tool, untested.</li>
+      tool of Microsoft's .NET framework 2.0.</li>
 
       <li><a href="wix.html">wix</a> - execute the WiX toolset, untested.</li>
 
diff --git a/docs/msbuild.html b/docs/msbuild.html
index 2ac93bc..2cfbcc5 100644
--- a/docs/msbuild.html
+++ b/docs/msbuild.html
@@ -9,9 +9,8 @@
 
     <h3>Description</h3>
 
-    <p>Runs the MSBuild build tool presented at the 2003 PDC.  This
-    task is completely untested as the developers have no access to
-    the tool, it has been implemented by looking at the docs only.</p>
+    <p>Runs the MSBuild build tool of Microsoft's .NET framework
+    2.0.</p>
 
     <p>You can either use an existing build file or nest a build file
     (snippet) as a child into the task.  If you don't specify either,
@@ -83,27 +82,28 @@
       &lt;msbuild&gt;
         &lt;target name="echo"&gt;
         &lt;build&gt;
-          &lt;Project DefaultTargets="empty"&gt;
+          &lt;Project DefaultTargets="empty" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
             &lt;Target Name="empty"/&gt;
             &lt;Target Name="echo"&gt;
-              &lt;Task Name="Echo" Message="This is MSBuild"/&gt;
+              &lt;Message Text="This is MSBuild"/&gt;
             &lt;/Target&gt;
           &lt;/Project&gt;
         &lt;/build&gt;
       &lt;/msbuild&gt;
     </pre>
 
-    <p>Run MSBuild's Echo task (if there actually is one):</p>
+    <p>Run MSBuild's Message task:</p>
 
     <pre>
       &lt;msbuild&gt;
         &lt;build&gt;
-          &lt;Task Name="Echo" Message="This is MSBuild"/&gt;
+          &lt;Message Text="This is MSBuild"
+             xmlns="http://schemas.microsoft.com/developer/msbuild/2003"/&gt;
         &lt;/build&gt;
       &lt;/msbuild&gt;
     </pre>
 
     <hr/>
-      <p align="center">Copyright &copy; 2003-2004 The Apache Software Foundation. All rights Reserved.</p>
+      <p align="center">Copyright &copy; 2003-2005 The Apache Software Foundation. All rights Reserved.</p>
   </body>
 </html>
\ No newline at end of file
diff --git a/src/etc/testcases/augment-path.xml b/src/etc/testcases/augment-path.xml
new file mode 100755
index 0000000..4a00a8d
--- /dev/null
+++ b/src/etc/testcases/augment-path.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project>
+  <property environment="env"/>
+  <path id="augmented-PATH">
+    <pathelement location="${framework.path}"/>
+    <pathelement location="${nunit.path}"/>
+    <pathelement location="${nant.path}"/>
+    <pathelement path="${env.PATH}"/>
+    <pathelement path="${env.Path}"/>
+  </path>
+  <property name="augmented.PATH" refid="augmented-PATH"/>
+</project>
\ No newline at end of file
diff --git a/src/etc/testcases/dotnetexec.xml b/src/etc/testcases/dotnetexec.xml
index 9b6e907..036448c 100644
--- a/src/etc/testcases/dotnetexec.xml
+++ b/src/etc/testcases/dotnetexec.xml
@@ -18,7 +18,8 @@
 <project name="dotnet" basedir="." default="testCSC"
   xmlns:dn="antlib:org.apache.ant.dotnet">
 
-  <property environment="env"/>
+  <import file="augment-path.xml"/>
+
   <property name="build.dir" location="build"/>
   <property name="src.dir" location="src"/>
 
@@ -27,18 +28,18 @@
   <property name="out.type" value="exe"/>
 
   <target name="probe_for_apps" >
+
    <condition property="csc.found">
       <or>
-        <available file="csc"     filepath="${env.PATH}" />
-        <available file="csc.exe" filepath="${env.PATH}" />
-        <available file="csc.exe" filepath="${env.Path}" />
+        <available file="csc"     filepath="${augmented.PATH}"/>
+        <available file="csc.exe" filepath="${augmented.PATH}"/>
       </or>
     </condition>
    <echo> csc.found=${csc.found}</echo>
 
    <!-- Mono C# compiler -->
    <condition property="mcs.found">
-      <available file="mcs"     filepath="${env.PATH}" />
+      <available file="mcs"     filepath="${augmented.PATH}"/>
     </condition>
    <echo> mcs.found=${mcs.found}</echo>
 
diff --git a/src/etc/testcases/msbuild.xml b/src/etc/testcases/msbuild.xml
index 2d94a8d..59515c7 100644
--- a/src/etc/testcases/msbuild.xml
+++ b/src/etc/testcases/msbuild.xml
@@ -17,49 +17,43 @@
 <project name="msbuild" basedir="." default="echo"
   xmlns:dn="antlib:org.apache.ant.dotnet">
 
-  <property environment="env"/>
+  <import file="augment-path.xml"/>
   <condition property="msbuild.found">
     <or>
-      <available file="MSBuild.exe" filepath="${env.PATH}"/>
-      <available file="MSBuild.exe" filepath="${env.Path}"/>
+      <available file="MSBuild.exe" filepath="${augmented.PATH}"/>
       <available file="MSBuild.exe"/>
     </or>
   </condition>
 
   <target name="echo">
-    <msbuild 
-      buildfile="src/msbuild.proj" 
-      xmlns="antlib:org.apache.ant.dotnet"
-      >
-      <target name="echo"/>
-      <property name="foo" value="bar"/>
-    </msbuild>
+    <dn:msbuild buildfile="src/msbuild.proj">
+      <dn:target name="echo"/>
+      <dn:property name="foo" value="bar"/>
+    </dn:msbuild>
   </target>
 
   <target name="nested-file">
     <property name="foo" value="bar"/>
-    <msbuild 
-      xmlns="antlib:org.apache.ant.dotnet"
-      >
-      <build>
-        <Project DefaultTargets="echo">
+    <dn:msbuild>
+      <dn:build>
+        <Project DefaultTargets="echo"
+          xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
           <Target Name="echo">
-            <Task Name="Echo" Message="foo is ${foo}"/>
+            <Message Text="foo is ${foo}"/>
           </Target>
         </Project>
-      </build>
-    </msbuild>
+      </dn:build>
+    </dn:msbuild>
   </target>
 
   <target name="nested-task">
     <property name="foo" value="bar"/>
-    <msbuild 
-      xmlns="antlib:org.apache.ant.dotnet"
-      >
-      <build>
-        <Task Name="Echo" Message="foo is ${foo}"/>
-      </build>
-    </msbuild>
+    <dn:msbuild>
+      <dn:build>
+        <Message Text="foo is ${foo}"
+                 xmlns="http://schemas.microsoft.com/developer/msbuild/2003"/>
+      </dn:build>
+    </dn:msbuild>
   </target>
 
 </project>
\ No newline at end of file
diff --git a/src/etc/testcases/nant.xml b/src/etc/testcases/nant.xml
index aa80f27..80080ff 100644
--- a/src/etc/testcases/nant.xml
+++ b/src/etc/testcases/nant.xml
@@ -14,14 +14,13 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project name="nant" basedir="." default="echo"
-  xmlns:dn="antlib:org.apache.ant.dotnet">
+<project name="nant" basedir="." default="echo">
 
-  <property environment="env"/>
+  <import file="augment-path.xml"/>
+
   <condition property="nant.found">
     <or>
-      <available file="NAnt.exe" filepath="${env.PATH}"/>
-      <available file="NAnt.exe" filepath="${env.Path}"/>
+      <available file="NAnt.exe" filepath="${augmented.PATH}"/>
       <available file="NAnt.exe"/>
     </or>
   </condition>
diff --git a/src/etc/testcases/nunit.xml b/src/etc/testcases/nunit.xml
index e03a2d5..c0e1d0d 100644
--- a/src/etc/testcases/nunit.xml
+++ b/src/etc/testcases/nunit.xml
@@ -17,14 +17,15 @@
 <project name="nunit" basedir="." default="echo"
   xmlns:dn="antlib:org.apache.ant.dotnet">
 
+  <import file="augment-path.xml"/>
+
   <property name="build.dir" value="build"/>
   <property name="src.dir" location="src"/>
 
   <property environment="env"/>
   <condition property="nunit.found">
     <or>
-      <available file="nunit-console.exe" filepath="${env.PATH}"/>
-      <available file="nunit-console.exe" filepath="${env.Path}"/>
+      <available file="nunit-console.exe" filepath="${augmented.PATH}"/>
       <available file="nunit-console.exe"/>
     </or>
   </condition>
diff --git a/src/etc/testcases/src/msbuild.proj b/src/etc/testcases/src/msbuild.proj
index ded05af..0fed54d 100644
--- a/src/etc/testcases/src/msbuild.proj
+++ b/src/etc/testcases/src/msbuild.proj
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
- Copyright  2003-2004 The Apache Software Foundation
+ Copyright  2003-2005 The Apache Software Foundation
 
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
@@ -14,11 +14,11 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<Project DefaultTargets="empty">
+<Project DefaultTargets="empty" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 
   <Target Name="empty"/>
 
   <Target Name="echo">
-    <Task Name="Echo" Message="foo is ${foo}"/>
+    <Message Text="foo is $(foo)"/>
   </Target>
 </Project>
diff --git a/src/main/org/apache/ant/dotnet/AbstractBuildTask.java b/src/main/org/apache/ant/dotnet/AbstractBuildTask.java
index 1eb8761..f2b64a8 100644
--- a/src/main/org/apache/ant/dotnet/AbstractBuildTask.java
+++ b/src/main/org/apache/ant/dotnet/AbstractBuildTask.java
@@ -247,7 +247,11 @@
             FileOutputStream out = null;
             try {
                 out = new FileOutputStream(f);
-                (new DOMElementWriter()).write(e, out);
+                DOMElementWriter w =
+                    new DOMElementWriter(true,
+                                         DOMElementWriter.XmlNamespacePolicy
+                                         .ONLY_QUALIFY_ELEMENTS);
+                w.write(e, out);
             } finally {
                 if (out != null) {
                     out.close();
diff --git a/src/main/org/apache/ant/dotnet/MSBuildTask.java b/src/main/org/apache/ant/dotnet/MSBuildTask.java
index 1641d1e..c8c2bde 100644
--- a/src/main/org/apache/ant/dotnet/MSBuildTask.java
+++ b/src/main/org/apache/ant/dotnet/MSBuildTask.java
@@ -32,6 +32,9 @@
 public class MSBuildTask extends AbstractBuildTask {
 
     private static final String TARGET = "generated-by-ant";
+    private static final String ROOT = "Project";
+    private static final String MSBUILD_NS =
+	"http://schemas.microsoft.com/developer/msbuild/2003";
 
     public MSBuildTask() {
         super();
@@ -53,7 +56,7 @@
 
     protected String[] getTargetArguments(List targets) {
         if (targets.size() > 0) {
-            StringBuffer sb = new StringBuffer("/targets:");
+            StringBuffer sb = new StringBuffer("/target:");
             Iterator iter = targets.iterator();
             boolean first = true;
             while (iter.hasNext()) {
@@ -102,13 +105,15 @@
         NodeList nl = f.getChildNodes();
         if (nl.getLength() == 1 
             && nl.item(0).getNodeType() == Node.ELEMENT_NODE
-            && nl.item(0).getNodeName().equals("Project")) {
+            && nl.item(0).getNodeName().equals(ROOT)) {
             return (Element) nl.item(0);
         } else {
-            Element p = f.getOwnerDocument().createElement("Project");
+            Element p = f.getOwnerDocument().createElementNS(MSBUILD_NS,
+							     ROOT);
             p.setAttribute("DefaultTargets", TARGET);
 
-            Element t = f.getOwnerDocument().createElement("Target");
+            Element t = f.getOwnerDocument().createElementNS(MSBUILD_NS,
+							     "Target");
             t.setAttribute("Name", TARGET);
 
             p.appendChild(t);