自动化每日构建(三)用NAnt来完成.NET工程的每日构建

2023-10-28 13:18

本文主要是介绍自动化每日构建(三)用NAnt来完成.NET工程的每日构建,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

过去写的文章,不过是英文的。后面有附带的 project.build 文件,你可以用项目的名称替换调******,并且加上代码更新,单元测试等具体内容,就可以做每日构建了。

 

Start a new .NET project by using Nant

 

This document has 5 sections:

Brief

System requirement

Directories and files

The Build file

Run Nant

 

 

Brief

Start a new .NET project by using Nant, so we can make Daily Building. All have to do list below:

1.Install .NET SDK1.0 and new version Nant, and make Nant works.

2.Copy Directories and files from nproject(n for .NET) template library.

3.Make project files stay in the right directory.

4.Edit the project.Build file. Let it fit the project.

5.Run Nant.

 

 

System requirement

.NET SDK1.0 or higher

Nant 0.84 or higher

 

Directories and files

You can make directories yourself, or copy from template. But make sure the directory tree like this:

Every directory is made for a certain kind of files. Directory names and what kind of files should be put in list below:

Directory        Files should be put in

            Build                building files

            Data                 project’s data files

            Doc                  project‘s documents for installation and deploying

            Lib                   libraries project depending on

            Res                  resources project using

                        Install               resources for installation

            Src                   project’ source files

                        Config              project’s configuration files

                        Database          project’s database files

                        cs                     project’s c# source code files

                        Docs                project’s documents for manager, developer, tester

                        Scripts              project’s script files

                        Sql                   project’s script files for database

           

Now put the .NET files into the /src/cs directory.

 

The Build file

            The build file is /build/project.build. In the template we already have a default build file. Because every project has different name and configuration, so we must edit the build file to suit project. We must edit the project name and path in the build file.

 

Run Nant

            After doing that, now start a command-line prompt, change path to ./build, and type nant. We can see a function list like this:

Now Nant runs. We can EDIT the build file to add new features: unit testing, packing, deploying, etc, as you like.

 

project.build 文件内容:

<?xml version="1.0" ?>
<project default="usage" basedir=".">
    <echo message="Using '${nant.settings.currentframework}' framework on '${nant.platform.name}' platform."/>

    <!-- =================================================================== -->
    <!-- Initialization target                                               -->
    <!-- =================================================================== -->
    <target name="init">
        <!-- You have to fill the ***** space with your project label.  -->
        <property name="Name" value="*****"/>
        <property name="name" value="*****"/>
     <property name="version" value="1.0" overwrite="false" />

     <echo message="------------------ ${Name}${version} Build  ------------------"/>

        <property name="s.home" value=".."/>
        <property name="s.src" value="${s.home}/src"/>
        <property name="s.srccs" value="${s.home}/src/cs"/>
        <property name="s.gohome" value="../"/>
        <property name="s.lib" value="${s.home}/lib"/>
        <property name="s.res" value="${s.home}/res"/>
        <property name="s.build" value="${s.home}/build"/>
        <property name="s.run" value="${s.home}/run"/>

        <property name="s.build.assemble" value="${s.build}/assemble"/>
        <property name="s.build.bin" value="${s.build.assemble}/bin"/>
        <property name="s.build.debug" value="${s.build.bin}/debug"/>
        <property name="s.build.gensrc" value="${s.build.assemble}/gen-src"/>
        <property name="s.build.apidocs" value="${s.build}/apidocs"/>
        <property name="s.build.lib" value="${s.home}/res"/>
        <property name="s.build.release" value="${s.build}/release"/>
        <property name="s.build.web"   value="${s.build}/web"/>
        <property name="s.build.dist"  value="${s.build}/dist"/>
        <property name="s.main" value="com"/>

        <tstamp>
            <format property="TODAY" pattern="d-MM-yy"/>
        </tstamp>

    </target>
    

    <!-- =================================================================== -->
    <!-- Help on usage                                                       -->
    <!-- =================================================================== -->
    <target name="usage">
        <echo message=""/>
        <echo message=""/>
        <echo message="***** Build file"/>
        <echo message="-------------------------------------------------------------"/>
        <echo message=""/>
        <echo message=" available targets are:"/>
        <echo message=""/>
        <echo message="   package   --> generates the *****.zip file (default)"/>
        <echo message="   compile   --> compiles the source code"/>
        <echo message="   test      --> unit test"/>
        <echo message="   release   --> build the installation package"/>
        <echo message="   deploy    --> deploy the application"/>
        <echo message="   clean     --> cleans up the directory"/>
        <echo message=""/>
        <echo message=" See the comments inside the *.build file for more details."/>
        <echo message="-------------------------------------------------------------"/>
        <echo message=""/>
        <echo message=""/>
    </target>
   
    <!-- =================================================================== -->
    <!-- Compiles the source directory                                       -->
    <!-- =================================================================== -->
    <target name="compile" depends="init">
        <mkdir dir="${s.build.bin}"/>
        <echo message=""/>
        <echo message="Compiling application main source..."/>
        <echo message="${s.srccs}/${name}/*.cs"/>

        <!-- You may change the compile tasks here.  -->
    
  <!-- first compile way: using solution task  -->
      <solution configuration="release" solutionfile="${s.srccs}/${name}/${name}.sln"
          outputdir="${s.build.bin}" />

  <!-- second compile way: using csc task for c# file  -->
  <!--
        <csc target="exe" warnaserror="true" debug="${debug}"
             output="${s.build.bin}/${name}.exe" >
            <sources failonempty="true">
                <includes name="${s.srccs}/${name}/*.cs" />
            </sources>
        </csc>  
        -->
       
    </target>
        


    <!-- =================================================================== -->
    <!-- Creates the zip package                                             -->
    <!-- =================================================================== -->
    <target name="package" depends="compile">

        <!-- You may change the package tasks here.  -->

    </target>


    <!-- =================================================================== -->
    <!-- Creates the deploy                                                  -->
    <!-- =================================================================== -->
    <target name="test" depends="compile">
   
  <!-- You may fill the tasks here.  -->
  
    </target>


    <!-- =================================================================== -->
    <!-- Creates the deploy                                                  -->
    <!-- =================================================================== -->
    <target name="deploy" depends="">
   
  <!-- You may fill the tasks here.  -->
  
    </target>

 

    <!-- =================================================================== -->
    <!-- Build the installation packge                                       -->
    <!-- =================================================================== -->
    <target name="release" depends="clean">
   
  <!-- You may fill the tasks here.  -->
  
    </target>

 

    <!-- =================================================================== -->
    <!-- Clean targets                                                       -->
    <!-- =================================================================== -->
    <target name="clean" depends="init">
        <delete dir="${s.build.assemble}"/>
        <delete dir="${s.build.release}"/>
       
  <!-- You may fill the tasks here.  -->
  
    </target>

   
</project>

<!-- End of file -->
   
    

这篇关于自动化每日构建(三)用NAnt来完成.NET工程的每日构建的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/293469

相关文章

Node.js net模块的使用示例

《Node.jsnet模块的使用示例》本文主要介绍了Node.jsnet模块的使用示例,net模块支持TCP通信,处理TCP连接和数据传输,具有一定的参考价值,感兴趣的可以了解一下... 目录简介引入 net 模块核心概念TCP (传输控制协议)Socket服务器TCP 服务器创建基本服务器服务器配置选项服

Python自动化处理手机验证码

《Python自动化处理手机验证码》手机验证码是一种常见的身份验证手段,广泛应用于用户注册、登录、交易确认等场景,下面我们来看看如何使用Python自动化处理手机验证码吧... 目录一、获取手机验证码1.1 通过短信接收验证码1.2 使用第三方短信接收服务1.3 使用ADB读取手机短信1.4 通过API获取

Rust中的Drop特性之解读自动化资源清理的魔法

《Rust中的Drop特性之解读自动化资源清理的魔法》Rust通过Drop特性实现了自动清理机制,确保资源在对象超出作用域时自动释放,避免了手动管理资源时可能出现的内存泄漏或双重释放问题,智能指针如B... 目录自动清理机制:Rust 的析构函数提前释放资源:std::mem::drop android的妙

Python自动化Office文档处理全攻略

《Python自动化Office文档处理全攻略》在日常办公中,处理Word、Excel和PDF等Office文档是再常见不过的任务,手动操作这些文档不仅耗时耗力,还容易出错,幸运的是,Python提供... 目录一、自动化处理Word文档1. 安装python-docx库2. 读取Word文档内容3. 修改

Python自动化办公之合并多个Excel

《Python自动化办公之合并多个Excel》在日常的办公自动化工作中,尤其是处理大量数据时,合并多个Excel表格是一个常见且繁琐的任务,下面小编就来为大家介绍一下如何使用Python轻松实现合... 目录为什么选择 python 自动化目标使用 Python 合并多个 Excel 文件安装所需库示例代码

JAVA调用Deepseek的api完成基本对话简单代码示例

《JAVA调用Deepseek的api完成基本对话简单代码示例》:本文主要介绍JAVA调用Deepseek的api完成基本对话的相关资料,文中详细讲解了如何获取DeepSeekAPI密钥、添加H... 获取API密钥首先,从DeepSeek平台获取API密钥,用于身份验证。添加HTTP客户端依赖使用Jav

10个Python自动化办公的脚本分享

《10个Python自动化办公的脚本分享》在日常办公中,我们常常会被繁琐、重复的任务占据大量时间,本文为大家分享了10个实用的Python自动化办公案例及源码,希望对大家有所帮助... 目录1. 批量处理 Excel 文件2. 自动发送邮件3. 批量重命名文件4. 数据清洗5. 生成 PPT6. 自动化测试

10个Python Excel自动化脚本分享

《10个PythonExcel自动化脚本分享》在数据处理和分析的过程中,Excel文件是我们日常工作中常见的格式,本文将分享10个实用的Excel自动化脚本,希望可以帮助大家更轻松地掌握这些技能... 目录1. Excel单元格批量填充2. 设置行高与列宽3. 根据条件删除行4. 创建新的Excel工作表5

nginx-rtmp-module构建流媒体直播服务器实战指南

《nginx-rtmp-module构建流媒体直播服务器实战指南》本文主要介绍了nginx-rtmp-module构建流媒体直播服务器实战指南,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有... 目录1. RTMP协议介绍与应用RTMP协议的原理RTMP协议的应用RTMP与现代流媒体技术的关系2

MySQL分表自动化创建的实现方案

《MySQL分表自动化创建的实现方案》在数据库应用场景中,随着数据量的不断增长,单表存储数据可能会面临性能瓶颈,例如查询、插入、更新等操作的效率会逐渐降低,分表是一种有效的优化策略,它将数据分散存储在... 目录一、项目目的二、实现过程(一)mysql 事件调度器结合存储过程方式1. 开启事件调度器2. 创