我在尝试让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
答案 0 :(得分:0)
解决。好吧,经过半天尝试不同的事情后,似乎是一个正斜线是问题,或者更确切地说是缺乏一个问题。以下行不正确:
<include name="${build.dir}APP3_DataClasses.dll" />
这是正确的行:
<include name="${build.dir}/APP3_DataClasses.dll" />
Stackoverflow再次救援。如果我不发布这个我不会更快找到问题:-)我现在有一堆其他错误,但至少这一个已经解决