【问题标题】:Mono: Using nant 0.92 to compile c#Mono:使用 nant 0.92 编译 c#
【发布时间】:2023-03-19 08:54:01
【问题描述】:

我在 Mono 框架中运行 nant 脚本时遇到问题。

当我使用 mono-3.5 运行 nant scipt 时出现此错误。

这是我的 nant scipt。

<target name="compile-libs" depends="prepare" description="Compile the libraries">
        <csc target ="library" output="${bin.lib.1}/lib.dll" debug="false">
        <sources>
                <include name="${src.lib.1}/${arg}/*"/>
        </sources>
      </csc>
</target>

这有什么问题?

然后,我改用bat文件编译c#。有用。但是,它只执行了第一个命令,然后就停止了。

echo compile lib1:
mcs /target:library /out:build\bin-lib-v1.0\lib.dll src-lib-v1.0\lib\%1\foo.cs
echo compile lib2:
mcs /target:library /out:build\bin-lib-v2.0\lib.dll src-lib-v2.0\lib\%1\foo.cs

bat 文件只生成了第一个库。它没有回显“编译 lib2”。

提前致谢!

【问题讨论】:

    标签: c# batch-file mono nant


    【解决方案1】:

    如果 mcs 是一个 bat 文件(做 where mcs 来检查是否是 mcs.bat ),当你调用另一个 bat 时在一个 bat 文件中

    mcs /target:library /out:build\bin-lib-v1.0\lib.dll src-lib-v1.0\lib\%1\foo.cs
    

    当前bat停止执行,并传递给mcs.bat而不返回

    你应该这样做:

    call mcs /target:library /out:build\bin-lib-v1.0\lib.dll src-lib-v1.0\lib\%1\foo.cs
    

    而不是nant(如果你更喜欢xml),只需使用msbuild(xbuild on mono),有一个类似的CSC任务,见http://msdn.microsoft.com/en-us/library/ms171479(v=vs.90).aspx

    更复杂场景的最佳(恕我直言)FAKE

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-06
      • 2012-01-06
      • 2014-02-08
      相关资源
      最近更新 更多