SubSonic Forums
All Your Database Are Belong To Us

Executing .exe after a NAnt build

Latest post 08-20-2008 1:14 PM by yitzchok. 3 replies.
  • 08-15-2008 11:31 AM

    Executing .exe after a NAnt build

    Ok I am starting to bang my head on the table here.

    I have used SubSonic for quite a while now, all on web apps. I am currently working on a console app and have got my classes generated fine, I can compile fine in VS 2005, I can even build using NAnt. However when I run the app I get this error:

    An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in SubSonic.dll

    Additional information: Can't find the SubSonicService section of the application config file

    I have created a very simple app to find the problem

    I have the app.config set up as follows:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
            <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false" />
        </configSections>
        <connectionStrings>
            <add name="CoreRoutingConnectionString" connectionString="server=OSSKNO-STAGING;database=CORE_ROUTING;trusted_connection=true" providerName="System.Data.SqlClient" />
        </connectionStrings>
        <SubSonicService defaultProvider="CoreRoutingConnectionString">
            <providers>
                <clear/>
                <add name="CoreRoutingConnectionString" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="CoreRoutingConnectionString" generatedNamespace="testSubsonic" includeTableList="tbl_Webservice_cancel_log" regexDictionaryReplace="tbl_Webservice_cancel_log,CancelLog;"/>
            </providers>
        </SubSonicService>
    </configuration>

    I read about SubSonic running in the context of a web app, so I have made reference to web.dll in my nant.build file like such:

    <?xml version="1.0"?>
    <project name="testSubsonic" default="build" basedir="." xmlns="http://nant.sf.net/schemas/nant.xsd">
        <target name="build">
            <delete dir="nant_build" />
            <mkdir dir="nant_build" />
            <csc target="exe" output="nant_build\testSubsonic.exe">
                <sources>
                    <include name="Generated\AllStructs.cs" />
                    <include name="Generated\CancelLog.cs" />
                    <include name="Generated\CancelLogController.cs" />
                    <include name="Generated\StoredProcedures.cs" />
                    <include name="Program.cs" />
                    <include name="Properties\AssemblyInfo.cs" />
                    <include name="Program.cs" />
                    <include name="Generated\*.cs" />
                </sources>
                <references>
                    <include name="SubSonic.dll" />
                    <include name="System.dll" />
                    <include name="System.configuration.dll" />
                    <include name="System.Data.dll" />
                    <include name="System.Web.dll" />
                    <include name="System.Xml.dll" />
                </references>
            </csc>
            <copy todir="nant_build">
                <fileset basedir=".">
                    <include name="*.exe" />
                    <include name="*.config" />
                    <include name="*.dll" />
                </fileset>
            </copy>
        </target>
    </project>


    I have even created a web.config with all the same info that is in the app.config. Does anybody know what I am doing wrong here. By the way this is using SubSonic version 2.1

    This set up is the same as what is in my vs project file, why does it error when compiled with NAnt?

    Thanks

  • 08-15-2008 12:37 PM In reply to

    Re: Executing .exe after a NAnt build

    Maybe this is the problem

    After the files are built do you have a file called testSubsonic.exe.config thats the file where you should put in the subsonic configuration.

    If I am I because I am I, and You are You because You are You, then I am I, and you are you. But If I am I because You are You, and You are You because I am I, then I am not I and You are not You. -Rabbi of Kotzk

  • 08-20-2008 8:55 AM In reply to

    Re: Executing .exe after a NAnt build

    Hi yitzchok,

    Sorry for not getting back to you sooner, I have been on other projects. That seemed to work. Thanks for the help. I just need to remember that little nugget. Seems odd that Subsonic will generate my classes by reading from an App or Web.config, but needs another config file to actually run without errors. Oh well all is ok now.

    Thanks again

     

  • 08-20-2008 1:14 PM In reply to

    Re: Executing .exe after a NAnt build

    SubSonic gets the configuration from System.Configuration class (so the config that is loaded with your app) and that is app.config where app is the assembly that runs so it is YourApplicationName.exe.config that gets loaded and when you build using VS then it renames the app.config to the right name in the bin folder (there should be a way to do this with NAnt and MSBuild)

    When generating the files SubSonic looks for and loads the app.config/web.config in the current working directory (or what you pass into /config)

    If I am I because I am I, and You are You because You are You, then I am I, and you are you. But If I am I because You are You, and You are You because I am I, then I am not I and You are not You. -Rabbi of Kotzk

Page 1 of 1 (4 items) | RSS