2009-07-16 62 views
0

我们有许多项目都有NAnt构建文件,我们可以从批处理文件运行这些文件。我们沿着这个方向前进,所以我们可以将构建绑定到Subversion钩子并自动运行测试。但是,当我们推F5时,NAnt构建的输出与VS产生的输出明显不同。如何在VS2005中按F5时运行NAnt构建和调试

我们希望能够覆盖F5行为做到以下几点:

  • 运行楠脚本来构建项目和依赖关系(编译文件是一个调试配置)。
  • 在调试模式下从目标目录启动项目,因此可以命中断点。

下面是我们构建文件一个样本:

<?xml version='1.0' ?> 
<project name='DWS.WI.Data.Common' default='all' xmlns='http://nant.sf.net/schemas/nant.xsd'> 
    <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> 
+0

你是否试图在nant内部进行调试?为什么不让它构建东西,然后打开解决方案并手动启动调试? – Eugene 2009-07-16 04:28:42

回答

1

你可能有你使用手动建立在开发机器东东VS解决方案。对于相同的二进制文件有两个独立的项目是一个不好的主意 - 即使你首先设法使其同步,也会很快地失去同步。

我建议你用你的解决方案文件,并有Visual Studio中的exec任务建造它​​,如果你必须使用楠:

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

的测试应该是作为试验项目的后期生成事件(的一部分再次运行,由VS本身),或者你可以在VS完成后运行它们。

以这种方式创建的二进制文件与手动运行Visual Studio完全兼容(假设您在同一个源代码树中打开相同的解决方案文件并选择相同的配置和平台)。

相关问题