NAnt与MSBuild使用(一)
来源:互联网 发布:seo外链推广 编辑:程序博客网 时间:2024/06/06 00:59
原文地址:http://chenglong01.blog.sohu.com/124044452.html
1.安装配置好NAnt等。
2.在D:\cl\NAnt\Test下编写NAt.bat批处理文件
@echo off
"D:\cl\NAnt\tools\NAnt0.86\Binary\nant-0.86-beta1\bin\NAnt.exe" %*
3.新建default.build文件,文件内容如下:
<?xml version="1.0" encoding="gb2312"?>
<project name="Test" default="run" basedir=".">
<property name="Solution1.Filename" value="D:\cl\NAnt\Test\Solution1\Solution1.sln"/>
<property name="Solution1.Configuration" value="DEBUG"/>
<property name="Build1.OutputFolder" value="D:\cl\NAnt\Test\result\"/>
<property name="Solution2.Filename" value="D:\cl\NAnt\Test\Solution2\Solution2.sln"/>
<property name="Solution2.Configuration" value="DEBUG"/>
<property name="Build2.OutputFolder" value="D:\cl\NAnt\Test\result\"/>
<target name="run">
<!--<call target="HelloNant"/>-->
<!--<call target="HelloWorld"/>-->
<!--<call target="implement"/>-->
<call target="build1"/>
<call target="build2"/>
</target>
<target name="build1">
<solution solutionfile="${Solution1.Filename}" outputdir="${Build1.OutputFolder}test" configuration="${Solution1.Configuration}"/>
</target>
<target name="build2">
<solution solutionfile="${Solution2.Filename}" outputdir="${Build2.OutputFolder}test" configuration="${Solution2.Configuration}"/>
</target>
<target name="build">
<mkdir dir="bin"/>
<csc target="exe" output="bin\HelloWorld.exe">
<sources>
<includes name="HelloWorld.cs"/>
</sources>
</csc>
</target>
<target name="implement" depends="build">
<exec program="bin\helloWorld.exe"/>
</target>
<target name="clean">
<delete dir="bin" failonerror="false"/>
</target>
<target name="HelloNant">
<echo message="Hello Nant"/>
</target>
<target name="HelloWorld">
<echo message="Hello World"/>
</target>
</project>
4.当然还有HelloWord.cs文件
5.在命令行运行NAnt会报错:
在命令行里运行nant,如下图
6.原因:NAnt不支持.NET FrameWork3.5,采用MSBuild编译,命令如下:
C:\Windows\Microsoft.NET\Framework3.5\V3.5\MSBuild.exe "D:\cl\NAnt\Test\Solution1\Solution1.sln" /t:Build /p:Configuration=Debug
执行成功,如下图:
7.建立批处理文件MsBuild.bat,内容如下
@echo off
C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe "D:\cl\NAnt\Test\Solution1\Solution1.sln" /t:Build /p:Configuration=Debug
C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe "D:\cl\NAnt\Test\Solution2\Solution2.sln" /t:Build /p:Configuration=Debug
8.更改default.build,如下:
<?xml version="1.0" encoding="gb2312"?>
<project name="Test" default="run" basedir=".">
<property name="Solution1.Filename" value="D:\cl\NAnt\Test\Solution1\Solution1.sln"/>
<property name="Solution1.Configuration" value="DEBUG"/>
<property name="Build1.OutputFolder" value="D:\cl\NAnt\Test\result\"/>
<property name="Solution2.Filename" value="D:\cl\NAnt\Test\Solution2\Solution2.sln"/>
<property name="Solution2.Configuration" value="DEBUG"/>
<property name="Build2.OutputFolder" value="D:\cl\NAnt\Test\result\"/>
<target name="run">
<exec program="msbuild.bat"/>
</target>
<target name="build1">
<solution solutionfile="${Solution1.Filename}" outputdir="${Build1.OutputFolder}test" configuration="${Solution1.Configuration}"/>
</target>
<target name="build2">
<solution solutionfile="${Solution2.Filename}" outputdir="${Build2.OutputFolder}test" configuration="${Solution2.Configuration}"/>
</target>
</project>
其实可以更简单点,如下:
<?xml version="1.0" encoding="gb2312"?>
<project name="Test" default="run" basedir=".">
<target name="run">
<exec program="msbuild.bat"/>
</target>
</project>
这就是NAnt调用MSBuild
- NAnt与MSBuild使用(一)
- nant的使用(一)-安装
- Nant 使用
- [转]MSBuild的简单介绍与使用
- NAnt安装与入门
- 使用NAnt构建入门
- nant的使用
- Nant使用简介
- Nant使用简介续
- 使用nant编译项目
- 使用Nant入门
- NAnt
- Nant
- nant的使用 (复制)
- NANT的使用—安装
- nant的使用(二)-基本原理之运行nant
- MSBuild使用初步
- MsBuild
- Linux下程序的调式(gdb)(1)
- flex实现自定义鼠标
- jQeury层布局插件
- struts学习笔记6
- qlikview的整体操作
- NAnt与MSBuild使用(一)
- redo 和 undo 之四
- linux串口编程 非规范模式 read()问题
- linux程序调试补充(gdb ) (2)
- 抽象方法与接口
- win7+cuda4.1+VS2008配置
- 《Linux设备驱动程序》学习2—高级字符设备驱动ioctl
- javascript 怎样才能确定参数变量的个数呢?
- C++之面向对象