You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dotnetexec.xml 2.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?xml version="1.0"?>
  2. <!--
  3. Copyright 2003-2004 The Apache Software Foundation
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. -->
  14. <project name="dotnet" basedir="." default="testCSC"
  15. xmlns:dn="antlib:org.apache.tools.ant.taskdefs.optional.dotnet">
  16. <property environment="env"/>
  17. <property name="build.dir" location="build"/>
  18. <property name="src.dir" location="src"/>
  19. <property name="out.csc" location="${src.dir}/out.cs"/>
  20. <property name="out.app" location="${build.dir}/out.exe"/>
  21. <property name="out.type" value="exe"/>
  22. <taskdef
  23. uri="antlib:org.apache.tools.ant.taskdefs.optional.dotnet"
  24. resource="org/apache/tools/ant/taskdefs/optional/dotnet/antlib.xml">
  25. <classpath>
  26. <pathelement location="../../../build/lib/dotnet.jar"/>
  27. </classpath>
  28. </taskdef>
  29. <target name="probe_for_apps" >
  30. <condition property="csc.found">
  31. <or>
  32. <available file="csc" filepath="${env.PATH}" />
  33. <available file="csc.exe" filepath="${env.PATH}" />
  34. <available file="csc.exe" filepath="${env.Path}" />
  35. </or>
  36. </condition>
  37. <echo> csc.found=${csc.found}</echo>
  38. <!-- Mono C# compiler -->
  39. <condition property="mcs.found">
  40. <available file="mcs" filepath="${env.PATH}" />
  41. </condition>
  42. <echo> mcs.found=${mcs.found}</echo>
  43. <!-- any C# compiler -->
  44. <condition property="c#.found">
  45. <or>
  46. <isset property="csc.found"/>
  47. <isset property="mcs.found"/>
  48. </or>
  49. </condition>
  50. </target>
  51. <target name="init" depends="probe_for_apps">
  52. <mkdir dir="${build.dir}"/>
  53. <property name="testCSC.exe"
  54. location="${build.dir}/ExampleCsc.exe" />
  55. </target>
  56. <target name="teardown">
  57. <delete dir="${build.dir}"/>
  58. </target>
  59. <target name="validate_csc" depends="init">
  60. <fail unless="c#.found">Needed C# compiler is missing</fail>
  61. </target>
  62. <target name="testCSC" depends="validate_csc">
  63. <csc
  64. destFile="${testCSC.exe}"
  65. targetType="exe">
  66. <src dir="${src.dir}" includes="ex*.cs"/>
  67. </csc>
  68. <available property="app.created" file="${testCSC.exe}"/>
  69. <fail unless="app.created">No app ${testCSC.exe} created</fail>
  70. <dn:dotnetexec executable="${testCSC.exe}" failonerror="true" />
  71. <delete file="${testCSC.exe}"/>
  72. </target>
  73. </project>