Nant <csc> build exe System.TypeInitializationException </csc>

时间:2010-11-05 22:21:13

标签: c# nant

我使用< csc target="exe">成功构建了多个项目。但是,当我尝试运行生成的exe时,我得到:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Quartz.Impl.StdSchedulerFactory' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Common.Logging, Version=1.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The system cannot find the file specified.
File name: 'Common.Logging, Version=1.2.0.0, Culture=neutral, PublicKeyToken=af0
8829b84f0328e'
   at Quartz.Impl.StdSchedulerFactory..cctor()

看起来Nant在构建时引用了dll,但是没有将依赖项复制到outputdir中,导致上面的运行时异常。有没有办法指示NAnt自动复制依赖项?必须多次运行exe以确定需要哪些依赖项并且&lt;非常繁琐。复制和GT;他们一个接一个地进入outputdir。

2 个答案:

答案 0 :(得分:1)

这将添加对项目的引用

<references basedir="References">
    <include name="Common.Logging.dll" />
</references>

这可用于将DLL复制到输出目录。您还可以使用通配符来包含所有dll。

<copy todir="${build.dir}">
    <fileset basedir="bin">
        <include name="Common.Logging.dll" />
    </fileset>
</copy>

答案 1 :(得分:0)

那时很乏味。 <copy> <copy> <copy>