ArticleDirectory
- 1.1 install Ruby
- 1.2 install rake and albacore
- 4.1, rakefile
- 4.2. Other functions provided by albacore
Microsoft tools are known for integration. automated building is generally based on Visual Studio or its plug-ins. In addition, Nant may be the ant. Net version in Java. Many open-source projects use Nant for automatic construction. My personal dislike of ant is that it is based on XML, and I have an instinctive dislike of XML, which does not comply with dry. There are too many duplicate and meaningless labels in XML, and the replacement of XML in the past few years may be yaml. However, with the popularity of web development in recent years, JSON has become the best choice to replace XML, standard databases in many languages have JSON parser, which further promotes the popularization of JSON data exchange formats.
Albacore is an automated build tool based on Ruby rake. Its syntax is consistent with that of Rake. It directly uses Visual Studio's solution and project files to get started easily.
1. Install Ruby in Environment 1.1
Albacore is based on Ruby rake, so you need to install Ruby first. I use cygwin, so you can install it directly. To install Ruby in windows, add Ruby to path. There are many Ruby installation tutorials on the Internet.
1.2 install rake and albacore
Rake is a build tool in Ruby and can be installed using GEM:
$ Gem install rake
Albacore is also a ruby package, which can also be installed using GEM:
$ Gem install albacore
2. A simple example
Suppose we have such a directory structure:
Now we create a rakefile in the root directory of the project (the same directory as solution) (This rakefile type is an automated build script with the build. XML in makefile or ant). The rakefile content is:
Require 'albacore' task: default => [: Build] msbuild: Build do | MSB. solution = "buylottery. sln "msb.tar gets: clean,: Build MSB. properties: configuration =>: releaseend
After the project is created, you can use the rake command in the directory to build the project.
3. Discussion
Ruby's metaprogramming is really awesome. You can see the programming of rakefile. Albacore uses Visual Studio's built-in msbuild and project definition files, which not only reduces the trouble, but also reduces the repetition. The rakefile function is centralized with the build task itself, the tedious tasks are still stored in the Visual Studio project file.
Here we have to mention rake. In rakefile, you can directly use Ruby scripts to write the tasks you want to complete, such as creating directories, moving files, and so on. All you need is the ruby language and its standard library.
Ruby is more like a platform here. Both gem, rake, and albocore are actually Ruby scripts.
4. rakefile syntax and functions provided by albacore 4.1, rakefile
The rakefile syntax is derived from makefile, which consists of tasks and dependencies (=>.
Task: default => [: Test] task: test do ruby "test/unittest. RB" End
The preceding rakefile has two tasks, one of which is default. If you directly use rake without the task name, the default task will be called. The second is test... You can use Ruby to complete any build task you want. For the default task, he points out its Dependencies with =>. The dependencies are a ruby array, which lists all dependencies of the task (actually a task ).
For more detailed rakefile definitions, see rakefile format.
4.2. Other functions provided by albacore
Albacore customizes some built-in tasks, such as msbuild used in our example. The goal of msbuild is to simplify the creation of rakefile tasks. In this example, you only need to specify the SLN file to build a project. Other tasks include:
Assemblyinfo-version number management is actually an operation on the assemblyinfo. CS file. Nunit -- nunit test ncoverconsole -- zip -- compress and Package
For other built-in tasks, see the code and examples on albacore GitHub.
5. Refer
Http://albacorebuild.net/
Https://github.com/Albacore/albacore
Https://github.com/Albacore/albacore/wiki/Getting-Started
Http://code-magazine.com/article.aspx? Quickid = 1006101 & page = 1
Http://rake.rubyforge.org/doc/rakefile_rdoc.html