How to replace the obsolete csc ant task

I have a mixed Java / C # project and use an ant script that contains a csc task to compile the dll. It works, but I get a warning

  [csc] This task is deprecated and will be removed in a future version
  [csc] of Ant.  It is now part of the .NET Antlib:
  [csc] http://ant.apache.org/antlibs/dotnet/index.html

How can I replace the csc task? I can of course create an exec task that calls nant with the project.build file, but this is absolutely wrong.

EDIT . To clarify: I mainly use this on Linux and writing a Nant script to compile part of a C # project is not a problem. Currently I call it ant script

<target name="build-mono-stuff">
    <exec executable="nant">
        <arg value="build-stuff"/>
    </exec>
</target>

but I was hoping to find a better solution than calling exec.

EDIT 2 So I tried to get nant from .NET AntLib to work. Here is how I guessed:

<taskdef name="mono-compile" classname="org.apache.ant.dotnet.build.NAntTask">
    <classpath location="lib/ant-dotnet-1.0.jar" />
</taskdef>
<target name="build-mono-stuff">
    <mono-compile buildfile="mono.build"></mono-compile>
</target>

First start:

[mono-compile] Cannot open assembly 'NAnt.exe': No such file or directory.

Then I put NAnt.exe from the Ubuntu nant package in PATH, and I get

[mono-compile] The "nant" section in the NAnt configuration file (/bin/NAnt.exe.config) is not available.

Any ideas?

+3
3

NAnt <msbuild> - msbuild.exe :

<!-- Ensure MSBuild is available -->
<property name="msbuild.dir"
          value="C:\WINDOWS\Microsoft.NET\Framework\v3.5"/>
<property name="msbuild.exe"
          value="${path::combine(msbuild.dir, 'MSBuild.exe')}"/>  
<fail message="MSBuild not fould in ${msbuild.dir}"
      unless="${file::exists( msbuild.exe )}"/>

<!-- Compile everything -->
<exec program="${msbuild.exe}">
  <arg file="NAntGraph2.sln"/>
  <arg value="/t:rebuild"/>
  <arg value="/verbosity:quiet"/>
</exec>

- ant script.

: , msbuild , .sln Visual Studio, 100% csc, , .

+1

.

, csc, *.csproj NANT script, .NET Ant Library.

http://ant.apache.org/antlibs/dotnet/index.html

Ant, .

+1

Without experience with Ant, I would do this in NAnt:

  <msbuild buildfile="foo.csproj">
    <property name="Configuration" value="Debug" />
    <!-- ... -->
  </msbuild>

You can transfer C # project files (or even Visual Studio solution files) directly to MSBuild. This should be much more convenient than through CSC. Find a list of common MSBuild properties here .

0
source

Source: https://habr.com/ru/post/1736696/


All Articles