自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Nant和Nunit構(gòu)建C#代碼

開發(fā) 后端
本文介紹Nant和Nunit構(gòu)建C#代碼,想用Nant和Nunit構(gòu)建C#代碼,可寫好build文件后運行UnitTest時遇到了麻煩。

以前沒使用Nant和Nunit構(gòu)建C#代碼的自動化構(gòu)建,今天自己寫了一個C#程序,想用Nant和Nunit構(gòu)建C#代碼。可寫好build文件后運行UnitTest時遇到了麻煩。命令行提示如下:
Could not load file or assembly 'nunit.framework, Version=2.4.3.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The system cannot find the file specified.
查了一下資料解決了這個問題。

解決方法是:

一、在該程序的config文件(如果程序名是money.dll,則該文件名為money.dll.config)中加入如下代碼: 

  1. <?xmlversionxmlversion="1.0"encoding="utf-8"?> 
  2. <configuration> 
  3. <runtime> 
  4. <assemblyBindingxmlnsassemblyBindingxmlns="urn:schemas-microsoft-com:asm.v1"> 
  5. <dependentAssembly> 
  6. <assemblyIdentitynameassemblyIdentityname="nunit.framework"
    publicKeyToken="96d09a1eb7f44a77"culture="Neutral"/> 
  7. <bindingRedirectoldVersionbindingRedirectoldVersion="2.0.6.0"newVersion="2.4.3.0"/> 
  8. <bindingRedirectoldVersionbindingRedirectoldVersion="2.1.4.0"newVersion="2.4.3.0"/> 
  9. </dependentAssembly> 
  10. </assemblyBinding> 
  11. </runtime> 
  12. </configuration> 

二、使用VS2005提供的gacutil把nant.core.dll 和 nant.framework.dll注冊一下。

具體做法是:

1、在window開始菜單用運行VS所帶的Visual Studio 2005 Command Prompt。

2、切換到nunit的bin目錄下

3、順序運行下列命令
gacutil /i nunit.core.dll
// 注冊core

gacutil /i nunit.framework.dll
//注冊framework

gacutil /l
//查看是否注冊上

三、大功告成。

現(xiàn)在運行 nant unittest 就完事大吉。

附 nant 的 build 文件如下:

  1. <?xmlversionxmlversion="1.0"?> 
  2. <projectnameprojectname="CSharpMoney"default="ut"> 
  3. <propertynamepropertyname="output.dir"value="../bin"/> 
  4. <propertynamepropertyname="output.dll"value="../bin/cs-money.dll"/> 
  5. <propertynamepropertyname="reports.dir"value="../reports"/> 
  6. <targetnametargetname="clean"> 
  7. <deletedirdeletedir="${output.dir}"/> 
  8. <deletedirdeletedir="${reports.dir}"/> 
  9. </target> 
  10. <targetnametargetname="copyfile"depends="clean"> 
  11. <mkdirdirmkdirdir="${output.dir}"unless="${directory::exists(output.dir)}"/> 
  12. <copyfilecopyfile="../nunit/bin/nunit.framework.dll"todir="${output.dir}"  
  13. if="${file::exists('nunit/bin/nunit.framework.dll')}"/> 
  14. </target> 
  15. <targetnametargetname="build"depends="copyfile"> 
  16. <csctargetcsctarget="library"output="${output.dll}"debug="true"> 
  17. <sources> 
  18. <includenameincludename="*.cs"/> 
  19. </sources> 
  20. <references> 
  21. <includenameincludename="../nunit/bin/nunit.framework.dll"/> 
  22. </references> 
  23. </csc> 
  24. </target> 
  25. <targetnametargetname="ut"depends="build"> 
  26. <mkdirdirmkdirdir="${reports.dir}"/> 
  27. <execprogramexecprogram="..NUnitunit-console.exe"> 
  28. <argvalueargvalue="${output.dll}"/> 
  29. <argvalueargvalue="/config=cs-money.dll.config"/> 
  30. <argvalueargvalue="/xml=${reports.dir}TestReport-Unit.xml"/> 
  31. <argvalueargvalue="/nologo"/> 
  32. <argvalueargvalue="/noshadow"/> 
  33. </exec> 
  34. </target> 
  35. </project> 

以上介紹Nant和Nunit構(gòu)建C#代碼

【編輯推薦】

  1. C#調(diào)用Windows API函數(shù)
  2. 詳解C#調(diào)用Outlook API
  3. C#連接Access、SQL Server數(shù)據(jù)庫
  4. 介紹C#調(diào)用API的問題
  5. C#調(diào)用Excel與附加代碼
責(zé)任編輯:佚名 來源: 百度空間
相關(guān)推薦

2009-08-19 15:30:40

C#復(fù)合控件構(gòu)建

2009-08-14 14:19:50

Enhanced LiC#構(gòu)建

2009-08-18 10:54:17

C#事件和委托

2011-05-18 17:56:38

C#C++

2011-05-18 18:05:47

C#C++

2009-08-13 17:04:09

C#語言C#程序

2009-08-27 16:11:03

C# delegateC# event

2009-08-06 16:30:58

C#代碼和驗證碼圖片

2009-08-19 16:50:32

Visual C#C#語言特性

2009-08-26 10:34:15

C#類型C#變量

2009-08-10 10:04:25

C#抽象類C#接口

2009-09-01 17:51:47

C#拆箱C#裝箱

2009-08-14 16:54:19

C# Hello Wo

2009-08-19 15:38:59

C#代碼

2009-09-07 06:48:13

C#透明窗體

2009-08-06 09:32:03

C#代碼協(xié)同執(zhí)行

2011-04-13 17:31:16

C#.NET

2009-09-01 10:37:51

C#項目代碼C#代碼規(guī)范

2009-08-13 17:36:54

編譯C#代碼

2009-09-02 17:12:06

C#關(guān)機代碼
點贊
收藏

51CTO技術(shù)棧公眾號