2009-07-16 65 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完全兼容(假設您在同一個源代碼樹中打開相同的解決方案文件並選擇相同的配置和平臺)。

相關問題