项目建立管理

来源:互联网 发布:pon网络由什么组成 编辑:程序博客网 时间:2024/05/17 00:51
项目建立管理

管理DLL

所有项目引用外来DLL(非本解决方案)都来自于同一个文件下,即在项目解决方案文件夹外,建立一个references文件夹,里面存放所有已经编译好的DLL。一旦引用外部DLL,那么其reference path 将显示地址。而工程与工程之间直接引用即可。

拷贝DLL

在编译某工程时将其DLL拷贝到指定文件下,便及时引用新的DLL。在Build Events-àpost build event command line中写命令,copy "$(TargetPath)" "c:/plus" 意思将该DLL拷贝到“c:/plus“目录下(使用DOS命令)

copy "$(SolutionDir)configuration/*.xml" "Q:/Plugins"
copy "$(SolutionDir)configuration/*.configuration" "Q:/Plugins"
copy "$(SolutionDir)configuration/*.config" "Q:/Plugins"
copy "$(SolutionDir)configuration/Icon/*.ico" "Q:/Plugins"
copy "$(SolutionDir)../reference/License.dll" "Q:/Plugins"
copy "$(SolutionDir)../reference/lmgr9a.dll" "Q:/Plugins"

$(SolutionDir) 表示该解决方案, "$(SolutionDir)configuration " 该解决方案下有文件configuration,

"*.xml" 表该文件下后缀为"xml"的文件

"$(SolutionDir)../reference/" 表示和该解决方案同级有文件 reference

xcopy "$(ProjectDir)LayerTemplate" "Q:/Plugins/LayerTemplate/" /R /Y 拷贝LayerTemplate下所有文件


 

设置该工程的命名空间

右击工程--->属性--->常规

加载测试代码

(1)已知Common工程,现要加载测试代码

<!--[if !supportLists]--> <!--[endif]-->新建一个工程,取名为Common_Test

<!--[if !supportLists]--> <!--[endif]-->只需拷贝“Common_Test.csproj“文件

<!--[if !supportLists]--> <!--[endif]-->粘贴到Common工程下,和“Common.csproj“同级,删除该Common_Test工程

<!--[if !supportLists]--> <!--[endif]-->然后在Common所属解决方案中,添加该Common_Test.csproj工程

如果存在引用其他DLL,必须对该DLL属性copy local = true

点击该Common_Test.csproj工程,再点击上方“显示所有文件 show all files

<!--[if !supportLists]-->Common下有文件PublicInfo,要保证Common_Test也有该文件,需右键点击PublicInfo文件,选择“引用到该工程 include in project

然后再Common_Test工程下建“Test”文件,所有Test代码都将此文件夹下

(2)为保证所有工程都只引用一个AssemblyInfo.cs文件,也就是解决方案不能与工程文件在一起。先建立一个解决方案,然后往该解决方案添加工程,把AssemblyInfo.cs文件放在和解决方案文件同级,所有工程文件都引用该处AssemblyInfo.cs

(3)为统一管理测试的DLL文件,可在解决方案中在添加一个文件为TestDll专门存放TestDLL。也就是编译时,应将DLL放置在TesTDll文件夹下



一个AssemblyInfo文件

保证一个解决方案中只有一个 AssemblyInfo.cs文件,也保证所有project也存在AssemblyInfo.cs,那么只要对该Project将其添加为Link File