views:

122

answers:

1

We have a number of projects that have NAnt build files that we can run from batch files. We went this direction so we can tie the builds to subversion hooks and automate running the tests. However, the output of the NAnt build is significantly different from what is generated by VS when we push F5.

We would like to be able to override the F5 behavior to do the following:

  • Run the NAnt Script to build the project and dependencies (the build file is a debug configuration).
  • Start the project from the target directory in debug mode so breakpoints can be hit.

Here is a sample of one of our build files:

<?xml version='1.0' ?>
<project name='DWS.WI.Data.Common' default='all' xmlns='http://nant.sf.net/schemas/nant.xsd'&gt;
    <property name='dbuild.dir' value='build\debug' />
    <property name='nant.settings.currentframework' value='net-2.0' />
    <property name='debug' value='true' />

    <!-- User targets -->
    <target name='all' />
    <target name='cleandeb' description='remove previous debug build files'>
     <delete dir='${dbuild.dir}' if='${directory::exists(dbuild.dir)}' />
    </target>
    <target name='init'>
     <mkdir dir='build' />
     <mkdir dir='build\debug' />
     <mkdir dir='build\release' />
    </target>
    <!-- -->
    <target name='debug' depends='cleandeb, init' description='Compiles the projects in debug mode'>
     <csc target='library' output='build\debug\${project::get-name()}.dll' rebuild='true' debug='true'>
      <sources>
       <include name='src\app\DWS.WI.Data.Common\*.cs' />
       <include name='src\app\DWS.WI.Data.Common\Properties\AssemblyInfo.cs' />
      </sources>
     </csc>
     <csc target='library' output='build\debug\DWS.WI.Data.Oracle.dll' rebuild='true' debug='true'>
      <references>
       <include name='build\debug\DWS.WI.Data.Common.dll' />
      </references>
      <sources>
       <include name='src\app\DWS.WI.Data.Oracle\*.cs' />
       <include name='src\app\DWS.WI.Data.Oracle\Properties\AssemblyInfo.cs' />
      </sources>
     </csc>
     <csc target='library' output='build\debug\DWS.WI.Data.SQL.dll' rebuild='true' debug='true'>
      <references>
       <include name='build\debug\DWS.WI.Data.Common.dll' />
       <include name='libs\Microsoft.SqlServer.ConnectionInfo.dll' />>
       <include name='libs\Microsoft.SqlServer.Smo.dll' />
       <include name='libs\Microsoft.SqlServer.SqlEnum.dll' />
      </references>
      <sources>
       <include name='src\app\DWS.WI.Data.SQL\*.cs' />
       <include name='src\app\DWS.WI.Data.SQL\Properties\AssemblyInfo.cs' />
      </sources>
     </csc>
    </target>
    <target name='test' depends='debug'>
     <csc target='library' output='build\debug\DWS.WI.Data.Fake.Test.dll' debug='true'>
      <sources>
       <include name='src\test\DWS.WI.Data.Fake.Test\*.cs' />
      </sources>
      <references>
       <include name='build\debug\DWS.WI.Data.Common.dll' />
       <include name='build\debug\DWS.WI.Data.Fake.dll' />
       <include name='tools\nunit\nunit.framework.dll' />
      </references>
     </csc>
    </target>
</project>
A: 

You probably have a VS solution that you use to build stuff manually on development machines. It is generaly a bad idea to have 2 separate projects for the same binary -- will get out of sync quite immidiately, even if you manage to bring it into sync in the first place.

I suggest you use your solution file and have visual studio build it with exec task if you must use nant:

<exec program="${environment::get-variable('VS80COMNTOOLS')}../IDE/devenv.com">
    <arg value="${solution_path}"/>
    <arg value="/build"/>
    <arg value="Debug|Win32"/>
</exec>

Tests should be either run as part of test project's post build events (again, by VS itself), or you can run them in nant after VS is done.

Binaries created this way would be exactly compatible with manual run of visual studio (assuming you open same solution file in the same source tree and select same configuration and platform).

Eugene