0

我在尝试让 NAnt 编译我的项目时遇到了麻烦,该项目由一个 Windows 窗体应用程序、一个实用程序库 (DLL) 和一个数据类库 (DLL) 组成。问题是在编译应用程序之前,我无法让主 WinEXE 应用程序引用作为第二步编译的数据类库。

这是我第一次涉足 NAnt(我决定在 MSBuild 之前尝试一下)。我正在使用 NAnt,因为我们想要使用的新 CI 服务器支持它。

在我上传构建配置文件并在服务器上尝试之前,我想我会在安装了 VS2005、VS2008 和 VS2010 的本地 PC 上尝试。服务器没有安装任何这些,只有各种 .NET 框架和 NAnt 二进制分发。

这是构建文件:

<?xml version="1.0"?>
<project name="APP3" default="build" basedir="..\">
<description>APP3 build</description>
<property name="nant.settings.currentframework" value="net-3.5" />
<property name="projectversion" value="3.8.0" />
<property name="project.config" value="debug" />

<target name="init">
    <call target="${project.config}" />
</target>

<target name="debug">
    <property name="project.config" value="debug" />
    <property name="build.debug" value="true" />
    <property name="basedir.suffix" value="-debug" />
</target>

<target name="release">
    <property name="project.config" value="release" />
    <property name="build.debug" value="false" />
    <property name="basedir.suffix" value="-release" />
</target>

<target name="clean">
    <delete file="${project::get-base-directory()}${project::get-name()}_${projectversion}${basedir.suffix}\APP3_DataClasses.dll" failonerror="false" />
    <delete file="${project::get-base-directory()}${project::get-name()}_${projectversion}${basedir.suffix}\classUtilities.dll" failonerror="false" />
    <delete file="${project::get-base-directory()}${project::get-name()}_${projectversion}${basedir.suffix}\APP3.exe" failonerror="false" />
</target>

<target name="build-classutilities" depends="init, clean" description="compiles the APP3 utilities class">
    <property name="build.dir" value="${project::get-base-directory()}/${project::get-name()}_${projectversion}${basedir.suffix}"/>
    <mkdir dir="${build.dir}" />
    <vbc target="library" output="${build.dir}/classUtilities.dll" debug="${build.debug}" rootnamespace="classUtilities">
        <imports>
            <import namespace="Microsoft.VisualBasic" />
            <import namespace="System" />
            <import namespace="System.Collections" />
            <import namespace="System.Collections.Generic" />
            <import namespace="System.Data" />
            <import namespace="System.Diagnostics" />
            <import namespace="System.Linq" />
            <import namespace="System.Xml.Linq" />
        </imports>
        <sources>
            <include name="${project::get-base-directory()}/classUtilities/Utilities.vb" />
        </sources>
        <resources>
            <include name="**/*.resources" />
        </resources>
        <references>
            <include name="System.dll" />
            <include name="System.Data.dll" />
            <include name="System.Core.dll" />
            <include name="System.Xml.dll" />
            <include name="System.Xml.Linq.dll" />
        </references>
    </vbc>
</target>

<target name="build-dataclasses" depends="build-classutilities" description="compiles the APP3 data classes">
    <property name="build.dir" value="${project::get-base-directory()}/${project::get-name()}_${projectversion}${basedir.suffix}"/>
    <mkdir dir="${build.dir}" />
    <vbc target="library" output="${build.dir}/APP3_DataClasses.dll" debug="${build.debug}" rootnamespace="APP3_DataClasses">
        <imports>
            <import namespace="Microsoft.VisualBasic" />
            <import namespace="System" />
            <import namespace="System.Collections" />
            <import namespace="System.Collections.Generic" />
            <import namespace="System.Configuration" />
            <import namespace="System.Data" />
            <import namespace="System.Diagnostics" />
            <import namespace="System.Xml" />
            <import namespace="System.Xml.Linq" />
            <import namespace="Iesi.Collections" />
            <!--<import namespace="NHibernate" />-->
        </imports>
        <sources>
            <include name="${project::get-base-directory()}/APP3_DataClasses/**/*.vb" />
        </sources>
        <resources>
            <include name="**/*.resources" />
            <include name="**/*.hbm.xml" />
        </resources>
        <references>
            <include name="System.dll" />
            <include name="System.Core.dll" />
            <include name="System.Xml.dll" />
            <include name="System.Xml.Linq.dll" />
            <include name="C:\Dev\NHibernate-2.1.2\Required_Bins\Iesi.Collections.dll" />
        </references>
    </vbc>
</target>

<target name="build" description="compiles the source code" depends="build-dataclasses">
    <property name="build.dir" value="${project::get-base-directory()}/${project::get-name()}_${projectversion}${basedir.suffix}"/>
    <mkdir dir="${build.dir}" />
    <vbc target="winexe" output="${build.dir}/APP3.exe" debug="${build.debug}" rootnamespace="APP3" main="APP3.My.MyApplication">
        <imports>
            <import namespace="APP3_DataClasses"/>
            <import namespace="classUtilities"/>
            <import namespace="Iesi.Collections"/>
            <import namespace="log4net"/>
            <import namespace="LumenWorks.Framework.IO.Csv" />
            <import namespace="Microsoft.Office.Interop.Word" />
            <import namespace="Microsoft.VisualBasic" />
            <import namespace="NHibernate" />
            <import namespace="System" />
            <import namespace="System.Collections" />
            <import namespace="System.Collections.Generic" />
            <import namespace="System.Configuration" />
            <import namespace="System.Data" />
            <import namespace="System.Data.SqlClient" />
            <import namespace="System.Diagnostics" />
            <import namespace="System.Drawing" />
            <import namespace="System.Windows.Forms" />
            <import namespace="System.IO" />
            <import namespace="System.Xml" />
        </imports>
        <sources>
            <include name="${project::get-base-directory()}/${project::get-name()}/**/*.vb" />
        </sources>
        <resources>
            <include name="**/*.resources" />
        </resources>
        <references>
            <include name="System.dll" />
            <include name="System.Data.dll" />
            <include name="System.Windows.Forms.dll" />
            <include name="System.configuration.dll" />
            <include name="System.Drawing.dll" />
            <include name="${build.dir}APP3_DataClasses.dll" />
            <include name="${build.dir}/classUtilities.dll" />
            <include name="System.Xml.dll" />
            <include name="C:\Dev\NHibernate-2.1.2\Required_Bins\Iesi.Collections.dll" />
            <include name="C:\Dev\NHibernate-2.1.2\Required_Bins\NHibernate.dll" />
            <include name="C:\Dev\NHibernate-2.1.2\Required_Bins\log4net.dll" />
            <include name="C:\Dev\LumenWorks.Framework\LumenWorks.Framework.3.8.1\LumenWorks.Framework.IO.dll" />
            <include name="C:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\Microsoft.Office.Interop.Word.dll" />
        </references>
    </vbc>
</target>

这是第一批输出,它持续了一段时间,但你从前几个错误中得到了要点:

NAnt 0.91 (Build 0.91.4312.0; release; 22/10/2011)
Copyright (C) 2001-2011 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///c:/Projects/Company/Windows Forms Applications/APP3-trunk/APP3/default.build
Target framework: Microsoft .NET Framework 4.0
Target(s) specified: build

[property] Target framework changed to "Microsoft .NET Framework 3.5".

init:


debug:


clean:

[delete] Deleting file c:\Projects\Company\Windows Forms Applications\APP3-trunk\APP3_3.8.0-debug\APP3_DataClasses.dll.
[delete] Deleting file c:\Projects\Company\Windows Forms Applications\APP3-trunk\APP3_3.8.0-debug\classUtilities.dll.

build-classutilities:

[vbc] Compiling 1 files to 'c:\Projects\Company\Windows Forms Applications\APP3-trunk\APP3_3.8.0-debug\classUtilities.dll'.

build-dataclasses:

[vbc] Compiling 24 files to 'c:\Projects\Company\Windows Forms Applications\APP3-trunk\APP3_3.8.0-debug\APP3_DataClasses.dll'.

build:

[vbc] Compiling 45 files to 'c:\Projects\Company\Windows Forms Applications\APP3-trunk\APP3_3.8.0-debug\APP3.exe'.
[vbc] vbc : error BC30420: 'Sub Main' was not found in 'APP3.My.MyApplication'.
[vbc] vbc : warning BC40057: Namespace or type specified in the project-level Imports 'APP3_DataClasses' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
[vbc] c:\Projects\Company\Windows Forms Applications\APP3-trunk\APP3\frmMain.vb(19) : error BC30002: Type 'Company' is not defined.
[vbc]
[vbc] c:\Projects\Company\Windows Forms Applications\APP3-trunk\APP3\frmMain.vb(49) : error BC30002: Type 'APP3_DataClasses.DataDictionary' is not defined.
[vbc]
[vbc]             APP3CompanyTypes = tQuery.List(Of APP3_DataClasses.DataDictionary)()
[vbc]                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[vbc] c:\Projects\Company\Windows Forms Applications\APP3-trunk\APP3\frmMain.vb(72) : error BC30002: Type 'APP3_DataClasses.Company' is not defined.
[vbc]
[vbc]             APP3Customers = tQuery.List(Of APP3_DataClasses.Company)()
[vbc]                                            ~~~~~~~~~~~~~~~~~~~~~~~~
[vbc] c:\Projects\Company\Windows Forms Applications\APP3-trunk\APP3\frmMain.vb(133) : error BC30002: Type 'APP3_DataClasses.DataDictionary' is not defined.
[vbc]
[vbc]                 Dim tType As APP3_DataClasses.DataDictionary
4

1 回答 1

0

解决了。好的,在尝试了半天不同的事情之后,似乎正斜杠是问题所在,或者更确切地说是缺少正斜杠。以下行不正确:

<include name="${build.dir}APP3_DataClasses.dll" />

这是正确的行:

<include name="${build.dir}/APP3_DataClasses.dll" />

Stackoverflow 再次进行救援。如果我不发布这个,我就不会更快地找到问题:-) 我现在还有很多其他错误,但至少这个问题已经解决

于 2012-04-05T04:43:41.950 回答