系列文章:

如何使用NAnt 自动打包DNN模块 之一

如何使用NAnt 自动打包DNN模块 之二

使用MSBuilder编译项目时,会出现找不到引用的DLL的问题。可以参考这里解决:http://www.beefycode.com/post/Resolving-Binary-References-in-MSBuild.aspx

安装完NAnt之后,我们就可以使用NAnt自动打包模块了。

跟使用NAnt完成其他任何一件任务一样,我们需要创建一个.build文件。大家可以下载我这个文件作为模板。

我们将使用MSBuilder来编译整个项目,使用NAnt把大部分文件压缩到一个Resource.zip文件,并最后制作出一个PA包和一个源代码包。

我们来仔细看看这个.builder文件,这是一个XML文件,root元素是一个project, 其中包含了若干个target元素,这些target元素就是关键了。这里我着重讲一下需要注意和根据需要修改的target元素,其它的部分大家可以自己看看,相信很容易理解。

先看看第一个:

初始化

<target name="init"><property name="nant.settings.currentframework" value="net-2.0" /><!-- .NET framework settings --><property name="dotNetFrameworkVersion" value="v3.5" overwrite="false" /><!-- This is where your packaged zips will build to from within the module folder --><property name="package.dir" value="package" overwrite="false" /><!-- This is where your resource.zip will be built so it can be zipped and distributed with the release install zips --><property name="resourcezip.dir" value="ResourceZip" /><property name="bin.dir" value="http://www.cnblogs.com/bin" /><property name="controls.dir" value="controls" /><property name="localresource.dir" value="App_LocalResources" /><property name="globalresource.dir" value="App_GlobalResources" /><property name="binZip" value="_Install" /><property name="srcZip" value="_Source" /><property name="rootWeb" value="http://localhost/" overwrite="false" /><property name="webAlias" value="DNN483Source" overwrite="false" /><property name="verbose" value="true" overwrite="false" /><!-- ModuleName value should be set specific to the project --><property name="CompanyName" value="AboutDNN" overwrite="false"/><property name="ModuleName" value="FlashImageRotator"  overwrite="false"  /><property name="subproject.name" value="${CompanyName}_${ModuleName}"/><property name="module.dll" value="${bin.dir}/${CompanyName}_${ModuleName}.dll" /><property name="debug" value="false" overwrite="false" /><property name="config" value="debug" if="${debug}" /><property name="config" value="release" unless="${debug}" /><sysinfo /><if test="${verbose}"><echo message="solutionName: ${subproject.name}" /><echo message="debug:        ${debug}" /><echo message="config:       ${config}" /></if></target>
 

这节里面初始化了一些跟项目有关的信息,其中最重要的是CompayName和ModuleName了。需要修改为你们自己的名称,这里还有一点要注意的是,注意看那个"subproject.nam”和"module.dll”,是由CompanyName和ModuleName组合而成的,所以你的.sln文件和DLL名称一定要符合这个规定。比如我的CompayName是"AboutDNN”,ModuleName是"FlashImageRotator”,那么我的.sln文件和DLL文件名就是这样的:

定义如何为PA包制作Resource.zip 文件:

<!-- Begin area for creating resourcezip for installable PA zips (should depend on target that clears where this will build zip file to)--><target name="CreateResourceZip" depends="CleanResourceZip"><!-- create a flat directory to zip for install --><mkdir dir="temp" unless="${directory::exists('temp')}" /><!-- DO NOT flatten this as we want to retain folder structure in this and ONLY this zip --><copy todir="temp" flatten="false"><fileset><!-- Tell nant what files to grab --><!-- everything included here ends up in resource.zip, this should be excluded in the CreateBinZip --><include name="**/images/*" /><include name="**/Flash/*" /><include name="**/Resources/**/*" /><include name="**/Docs/*.pdf" /><include name="**/${localresource.dir}/*.resx" /><include name="**/${globalresource.dir}/*.resx" /><include name="**/${globalresource.dir}/*.xml" /><include name="**/*.ascx" /><include name="**/*.css" /><include name="**/*.aspx" /><exclude name="**/DNNDebug.aspx" /><exclude name="**/Resources.zip" /><exclude name="**/Install/**/*" /><exclude name="**/_sgbak/*" /><exclude name="**/thumbs.db" /><exclude name="**/*.zip" /><exclude name="**/docs/images/*" /></fileset></copy><mkdir dir="${resourcezip.dir}" unless="${directory::exists(resourcezip.dir)}" /><zip zipfile="${resourcezip.dir}/Resources.zip"><fileset basedir="temp"><include name="**/*" /><exclude name="**/*.dll" /></fileset></zip><!--Delete temp directory --><delete dir="temp" failonerror="false" /></target>

修改fileset部分就可以定义那些文件会打包进PA安装包的

制作源代码包的zip文件

<target name="CreateResourceSourceZip" depends="CleanResourceZip"><!-- create a flat directory to zip for install --><mkdir dir="temp" unless="${directory::exists('temp')}" /><!-- DO NOT flatten this as we want to retain folder structure in this and ONLY this zip --><copy todir="temp" flatten="false"><fileset><!-- Tell nant what files to grab --><!-- everything included here ends up in resource.zip, this should be excluded in the CreateBinZip --><include name="**/images/*" /><include name="**/Themes/**/*" /><include name="**/Resources/**/*" /><include name="**/Documentation/**" /><include name="**/${localresource.dir}/*.resx" /><include name="**/${globalresource.dir}/*.resx" /><include name="**/${globalresource.dir}/*.xml" /><include name="**/*.ascx" /><include name="**/*.aspx" /><include name="**/*.cs" /><include name="**/*.sln" /><include name="**/*.csproj" /><include name="**/*.build" /><exclude name="**/DNNDebug.aspx" /><exclude name="**/Install/**/*" /><exclude name="**/_sgbak/*" /><exclude name="**/thumbs.db" /><exclude name="**/*.zip" /><exclude name="**/04.03.02.txt" /></fileset></copy><mkdir dir="${resourcezip.dir}" unless="${directory::exists(resourcezip.dir)}" /><zip zipfile="${resourcezip.dir}/Resources.zip"><fileset basedir="temp"><include name="**/*" /><exclude name="**/*.dll" /></fileset></zip><!--Delete temp directory --><delete dir="temp" failonerror="false" /></target>

设置版本号

最后我们要保证在AssemblyInfo.cs文件中,正确的设置了一个版本号,这样NAnt会自动读取这个版本号,并生成对应的打包文件。

 

到这里,就修改完.builder文件了。其实对于大家来说,只需要修改初始化部分的公司名称和项目名称就可以了,其它部分都可以使用默认的设置。

最后我们来让NAnt帮我们打包模块,进入到你模块所在的目录,键入NAnt命令:

NAnt之后就会卖力的编译模块和打包,哈,25秒搞定:

打包好的模块:

如何使用NAnt 自动打包DNN模块 之二相关推荐

  1. 【Flutter】如何写一个Flutter自动打包成iOS代码模块的脚本

    相信很多使用原生+Flutter的iOS项目都会遇到混合开发的集成问题,也有大神写了一些解决方案,下面就记录一下我的心路历程: 前期准备 开始之前,我先拜读了一些大神的文章(这里只挑出对我帮助最大的) ...

  2. OpenCV4学习笔记(67)——dnn模块之基于colorization模型实现图像自动上色

    本次要整理记录的内容是利用colorization模型来将灰度图像转换为彩色图像.colorization模型是利用Lab色彩空间的L(亮度)通道来预测a.b两个通道的值,也就是说当我们手里有一张灰度 ...

  3. webpack 的基本使用——配置打包的入口与出口||配置 webpack 的自动打包功能

    配置打包的入口与出口 const path = require('path') // 导入 node.js 中专门操作路径的模块 module.exports = { entry: path.join ...

  4. ios 自动打包命令_iOS:使用jenkins实现xcode自动打包(最新)

    参考各种教程实现Jenkins自动化打包遇到点坑,特此把自己成功安装的步骤记录一下. 一.安装jenkins 首先使用osx系统自带的homebrew来安装jenkins. 在终端中运行:$ brew ...

  5. opencv dnn模块 示例(15) opencv4.2版本dnn支持cuda加速(vs2015异常解决)

    opencv在4.2.0版本正式发布,DNN深度神经网络模块集成Google Summer of Code的项目CUDA后端支持.(详细changelog) 1.编译 常规编译过程,这里使用软硬件环境 ...

  6. Spring Boot + Vue前后端分离项目,Maven自动打包整合

    前言 现在各类项目为了降低项目.服务模块间的高度耦合性,提出了"前后端分离",而前后端分离的项目该如何打包呢? 一般的做法是前端项目打包完,将打包文件手动复制到后端项目工程的src ...

  7. 用opencv的dnn模块做yolov5目标检测

    最近在微信公众号里看到多篇讲解yolov5在openvino部署做目标检测文章,但是没看到过用opencv的dnn模块做yolov5目标检测的.于是,我就想着编写一套用opencv的dnn模块做yol ...

  8. ios 自动打包命令_iOS自动打包上传脚本

    自从将swift2.2升级到swift3.0, 每次使用Xcode8编译都很慢,很是不爽,于是有了研究下xcodebuild命令行打包的想法,起初不知道用shell,还是用python, 在网上大概搜 ...

  9. fastlane自动打包--详细介绍

    fastlane--Packaging 自动化打包,通过fastlane自动发布 Fastlane安装不在这里详细罗列,参照一下链接流程 https://www.jianshu.com/p/0a113 ...

最新文章

  1. 算法-----------数组------------只出现一次的数字
  2. POJ-2746:约瑟夫问题(Java版)
  3. 使用Apriori进行关联分析(一)
  4. 设置jstree只展示到2级_你做的私域流量属于什么级别?80%的商家都还只在第2级...
  5. Ubuntu Qt 编译问题
  6. javaWeb(入门基础详解)
  7. python程序设计课后答案第三单元_最新Python程序设计课后习题答案-第一单元
  8. 提高前端生产效率(PxCook工具推荐)
  9. 头条小程序对接微信、支付宝
  10. SWIFT gpi Instant 成功与新加坡 FAST 进行全球测试
  11. 手绘 | 我说话直,你别介意——我呸!
  12. Unix时间戳 怎么计算
  13. 使用python代码举例说明离散随机变量
  14. 打造汽车“安卓平台”,大众或亲手干掉传统汽车产业
  15. Vue——路由变化页面数据不刷新问题
  16. 51单片机const unsigned char number[16]是啥意思
  17. 天选2 使用微PE工具箱制作PE盘、进入PE系统
  18. 用engineeercms实现企业实时文档协作
  19. http://blog.csdn.net/jrq/article/details/4211075(URL参数中文乱码)
  20. 自己动手去除app中谷歌广告

热门文章

  1. php程序应用实例,PHP教程.应用实例1_php
  2. go io.reader 多次读取_Go 语言进阶:freecache 源码学习(1)
  3. php广告轮播效果,使用swiper组件实现轮播广告效果
  4. html阅读开放试用阶段,泰克为不同行业提供100种应用功能免费试用
  5. 图解phpstorm常用快捷键
  6. switch case穿透Java_Switch语句的case穿透
  7. tc写入txt成功却没有内容_挖洞经验 | 构造UserAgent请求头内容实现LFI到RCE提权
  8. 花了我一天一夜整理出的软件测试学习路线
  9. python的难点_汇总Python初学者常见的学习难点
  10. 怎么将jsp中var报错_招聘中不得将全日制作为限制性条件,怎么就不公平了?