如何使用MSBuild Community Tasks

为什么我们需要MSBuild Community Tasks

通常我们在做Daily Build时候我们需要编写项目的一堆post build脚本,复杂一点的定制化功能我以前使用NANT来完成。但采用Nant脚本对于微软控来说总觉得不是原生的,最近在做DNN模块的时候,Christoc提供的DNN项目模板采用了MSBuild Community Tasks来定制化Post Build脚本。MSBuild原生Task+社区的支持=主流,那赶紧学吧。

 

MSBuild Community Tasks如何使用

1、首先到如下网址下载最新版本,

https://github.com/loresoft/msbuildtasks

 

2、在项目中使用MSBuild Community Tasks

如果你现在已经在使用VS2010或者2012、2013那么你可以通过Nuget来快速安装MSBuild Community Tasks。步骤如下:

a.打开Package Manager Console

b.在控制台输入Install-Package MSBuildTasks

c.输入完成后会在Solution目录下生成一个.build目录

d.在文本编辑器中打开你想要定制化Post Build的项目文件,并在项目文件中引用MSBuild Community Tasks.

 

然后在项目文件中添加你要通过MSBuild完成的Targets文件

e.接着在项目文件的末尾定义如何调用你编写的Targets,示例中是在AfterBuild时触发

现在你可以自己尝试一下做个build来尝试一下了! Good Luck!

 

附录(MSBuild Community Tasks支持的Task列表)

 

Task                    Description        
            Add                    Add numbers        
            AddTnsName                    Defines a database host within the Oracle TNSNAMES.ORA file.        
            AppPoolController                    Allows control for an application pool on a local or remote machine with IIS installed. The default is to control the application pool on the local machine. If connecting to a remote machine, you can specify the and for the task to run under.        
            AppPoolCreate                    Creates a new application pool on a local or remote machine with IIS installed. The default is to create the new application pool on the local machine. If connecting to a remote machine, you can specify the and for the task to run under.        
            AppPoolDelete                    Deletes an existing application pool on a local or remote machine with IIS installed. The default is to delete an existing application pool on the local machine. If connecting to a remote machine, you can specify the and for the task to run under.        
            AssemblyInfo                    Generates an AssemblyInfo files        
            Attrib                    Changes the attributes of files and/or directories        
            Beep                    A task to play the sound of a beep through the console speaker.        
            BuildAssembler                    BuildAssembler task for Sandcastle.        
            ChmBuilder                    ChmBuilder task for Sandcastle.        
            ChmCompiler                    Html Help 1x compiler task.        
            Computer                    Provides information about the build computer.        
            DBCSFix                    DBCSFix task for Sandcastle.        
            Divide                    Divide numbers        
            ExecuteDDL                    MSBuild task to execute DDL and SQL statements.        
            FileUpdate                    Replace text in file(s) using a Regular Expression.        
            FtpCreateRemoteDirectory                    Creates a full remote directory on the remote server if not exists using the File Transfer Protocol (FTP). This can be one directory or a full path to create.        
            FtpDirectoryExists                    Determ if a remote directory exists on a FTP server or not.        
            FtpUpload                    Uploads a group of files using File Transfer Protocol (FTP).        
            FtpUploadDirectoryContent                    Uploads a full directory content to a remote directory.        
            FxCop                    Uses FxCop to analyse managed code assemblies and reports on their design best-practice compliance.        
            GacUtil                    MSBuild task to install and uninstall asseblies into the GAC        
            GetSolutionProjects                    Retrieves the list of Projects contained within a Visual Studio Solution (.sln) file        
            HxCompiler                    A Html Help 2.0 compiler task.        
            ILMerge                    A wrapper for the ILMerge tool.        
            InstallAspNet                    Installs and register script mappings for ASP.NET        
            InstallAssembly                    Installs assemblies.        
            JSCompress                    Compresses JavaScript source by removing comments and unnecessary whitespace. It typically reduces the size of the script by half, resulting in faster downloads and code that is harder to read.        
            Mail                    Sends an email message        
            Merge                    Merge files into the destination file.        
            Modulo                    Performs the modulo operation on numbers.        
            MV                    Moves files on the filesystem to a new location.        
            MRefBuilder                    MRefBuilder task for Sandcastle.        
            Multiple                    Multiple numbers        
            NDoc                    Runs the NDoc application.        
            NUnit                    Run NUnit 2.4 on a group of assemblies.        
            Prompt                    Displays a message on the console and waits for user input.        
            RegexMatch                    Task to filter an Input list with a Regex expression. Output list contains items from Input list that matched given expression        
            RegexReplace                    Task to replace portions of strings within the Input list Output list contains all the elements of the Input list after performing the Regex Replace.        
            RegistryRead                    Reads a value from the Registry        
            RegistryWrite                    Writes a value to the Registry        
            RoboCopy                    Task wrapping the Window Resource Kit Robocopy.exe command.        
            Sandcastle                    The Sandcastle task.        
            Script                    Executes code contained within the task.        
            ServiceController                    Task that can control a Windows service.        
            ServiceQuery                    Task that can determine the status of a specified service on a target server.        
            Sleep                    A task for sleeping for a specified period of time.        
            Sound                    A task to play a sound from a .wav file path or URL.        
            SqlExecute                    Executes a SQL command.        
            SqlPubWiz                    The Database Publishing Wizard enables the deployment of SQL Server databases (both schema and data) into a shared hosting environment.        
            Subtract                    Subtract numbers        
            SvnCheckout                    Checkout a local working copy of a Subversion repository.        
            SvnClient                    Subversion client base class        
            SvnCommit                    Subversion Commit command        
            SvnCopy                    Copy a file or folder in Subversion        
            SvnExport                    Export a folder from a Subversion repository        
            SvnInfo                    Run the "svn info" command and parse the output        
            SvnUpdate                    Subversion Update command        
            SvnVersion                    Summarize the local revision(s) of a working copy.        
            TaskSchema                    A Task that generates a XSD schema of the tasks in an assembly.        
            TemplateFile                    MSBuild task that replaces tokens in a template file and writes out a new file.        
            TfsVersion                    Determines the changeset in a local Team Foundation Server workspace        
            Time                    Gets the current date and time.        
            UninstallAssembly                    Uninstalls assemblies.        
            Unzip                    Unzip a file to a target directory.        
            User                    Provides information about the build user.        
            Version                    Generates version information based on various algorithms        
            VssAdd                    Task that adds files to a Visual SourceSafe database.        
            VssCheckin                    Task that executes a checkin against a VSS Database.        
            VssCheckout                    Task that executes a checkout of files or projects against a Visual SourceSafe database.        
            VssClean                    Task that can strip the source control information from a Visual Studio Solution and subprojects.        
            VssDiff                    Task that records differences between the latest version of all the items in a Visual SourceSafe project and another version or label to a file.        
            VssGet                    Task that retireves an item or project from a Visual SourceSafe database.        
            VssHistory                    Generates an XML file containing details of all changes made to a Visual SourceSafe project or file between specified labels or dates.        
            VssLabel                    Task that applies a label to a Visual SourceSafe item.        
            VssUndoCheckout                    Task that undoes a checkout of files or projects against a Visual SourceSafe database.        
            WebDirectoryCreate                    Creates a new web directory on a local or remote machine with IIS installed. The default is to create the new web directory on the local machine. The physical path is required to already exist on the target machine. If connecting to a remote machine, you can specify the and for the task to run under.        
            WebDirectoryDelete                    Deletes a web directory on a local or remote machine with IIS installed. The default is to delete the web directory on the local machine. If connecting to a remote machine, you can specify the and for the task to run under.        
            WebDirectoryScriptMap                    Sets an application mapping for a filename extension on an existing web directory.        
            WebDirectorySetting                    Reads and modifies a web directory configuration setting.        
            WebDownload                    Downloads a resource with the specified URI to a local file.        
            XmlMassUpdate                    Performs multiple updates on an XML file        
            XmlQuery                    Reads a value or values from lines of XML        
            XmlRead                    Reads a value from a XML document using a XPath.        
            XmlUpdate                    Updates a XML document using a XPath.        
            Xslt                    A task to merge and transform a set of xml files.        
            XslTransform                    XslTransform task for Sandcastle.        
            Zip                    Create a zip file with the files specified.        
             * Items not complete or have not been released.

 

参考:

https://github.com/loresoft/msbuildtasks 官网

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值