NAnt vbc build error loading custom DLL reference

Go To StackoverFlow.com

0

I am having trouble trying to get NAnt to compile my project, which consists of a windows forms application, a utilities library (DLL) and a data classes library (DLL). The problem is that I can't get the main WinEXE application to reference the data classes library, which gets compiled as the second step, before the app is compiled.

This is my first foray into NAnt (I have decided to try this before MSBuild). I am using NAnt because it is supported by our new CI server, which we want to use.

Before I upload a build configuration file and try this on the server I thought I'd try it on my local PC, which has VS2005, VS2008 and VS2010 installed. The server does not have any of those installed, just the various .NET frameworks and the NAnt binary distribution.

Here is the build file:

<?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>

And here is the first lot of output, it goes on for a while, but you get the gist from the first couple of errors:

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
2012-04-04 03:25
by Dominik
SOLVED. OK, after half a day of trying different things it seems that a forward slash was the issue, or rather the lack of one. The following line is incorrect:

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

This is the correct line:

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

Stackoverflow to the rescue again. If I wouldn't have posted this I wouldn't have found the issue any quicker :-)

I have a bunch of other errors now but at least this one is resolved - Dominik 2012-04-04 03:30



0

SOLVED. OK, after half a day of trying different things it seems that a forward slash was the issue, or rather the lack of one. The following line is incorrect:

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

This is the correct line:

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

Stackoverflow to the rescue again. If I wouldn't have posted this I wouldn't have found the issue any quicker :-) I have a bunch of other errors now but at least this one is resolved

2012-04-05 04:43
by Dominik
Ask the Duck principle in action ;- - Yan Sklyarenko 2012-04-05 06:26
Ads