Zealot's Blog

Coding life...

公告

统计

2005年10月29日

.NET 2.0 之 MSBuild 初体验

net 2.0发布了,手痒,想用却不在家,在MM的机器上下载了SDK,安装完成后马上打开文档,浏览我感兴趣的部分,msbuild跃入眼帘,这个之前在msdn tv show里看到过的咚咚一直是我感兴趣的。
功能还是很强大的,build大型项目非常有优势, 马上看文档,简单了解Item、Properties、Targets、Tasks之后,马上体验:

  1. 写一个简单的proj或sln文件,在其中添加简单的Item、Properties、Targets、Tasks
    <Project DefaultTargets = "Compile"
        xmlns
    ="http://schemas.microsoft.com/developer/msbuild/2003" >
        
    <PropertyGroup>
            
    <appname>formtestappname>
        
    PropertyGroup>
        
    <ItemGroup>
            
    <CSFile Include = "formtest.cs"/>
        
    ItemGroup>

        
    <Target Name = "Compile">
            
    <CSC
                
    Sources = "@(CSFile)"
                OutputAssembly 
    = "$(appname).exe">
                
    <Output
                    
    TaskParameter = "OutputAssembly"
                    ItemName 
    = "WEXEFile" />
            
    CSC>
            
    <Message Text="The output file is @(EXEFile)"/>
        
    Target>
    Project>
  2. 在命令行下运行msbuild,如果在当前目录中只有一个sln或proj文件时,连项目文件名都省了,开始编译、输出
     msbuild.JPG
  3. 待续...

MSBuild非常适合没有IDE或因为项目过大IDE无法有效处理或日构建时使用。

posted @ 2005-10-29 01:50 Zealot 阅读(1213) 评论(0) 编辑