开发者

How to automate the build process?

How can I automate the w开发者_JAVA百科eb-application build process, that includes following steps:

  • Change connection string.
  • Recreate database by scripts.
  • Deploy web-site by ftp.
  • Copy some files to server in addition to application.
  • And may be perform some initialize operations.

Should I write any script/programm, use Visual Studio or any another program?


Personally I use a Continuous Integration tool to do this kind of work.

The one I mainly use is Team City by JetBrains.

This kind of software can look at your Source Control repo for new checking, perform builds, publish builds to servers as well as running pre/post build events.


You've to start learning MSBuild. It is VERY simple and straightforward, so just start and you'll see ;)

In adddition to built in features it has Community Pack with many tasty things so you will be able to:

  • Replace connection string in config file using regex or replace whole config with predefined connection string (FileUpdate or Copy task)
  • Execute database scripts (MSBuild.Community.Tasks.SqlServer.ExecuteDDL)
  • Deploy site using Copy task

And many other...


You can run pre and post events in Visual Studio. To do this, simply right click on the project and in the project properties navigate to the 'Build Events' options. Here you can specify the pre and post build events (you can also specify when the event runs - on successful build or otherwise).

Once the project has been successfully built, the post build event can be set up to perform the tasks specified. You can detail the steps either in a separate file or in Visual Studio project's build events itself.

More information

  • Pre/Post Build event command line arguments
  • How to: Specify Build Events (C#)


Much along the continuous integration concept Jamie mentions, we use BuildMaster internally for all of our applications since we develop it :)

Now that we have a version offered for free, I'll share some thoughts on each of your bullet points:

Change connection string

This is something that is handled uniquely by the tool. Each environment would get its own "instance" of a configuration file and in a deployment plan you can use the "deploy configuration files" action to put them in any environment. This means there are no transforms to worry about since the config file is stored and versioned within the tool.

Recreate database by scripts

This is another major feature we have. Object code (stored procs, views, etc.) can be run every time with a DROP/CREATE combo, but adding indexes, dropping columns, can only be done once (you can't bring a column's data back without a restore!)

BuildMaster handles these types of change scripts differently - they can only be run at most once against an environment's instance of your database. This makes it super easy to bring any new or existing initialized database schema up-to-date.

Deploy web-site by FTP

Just add an action to your deployment plan, and you click Create Build or Promote Build, it will do that.

Copy some files to server in addition to application

If the process is repeatable you can do this easily, if need be by using a manual action that will remind you to do it.

And may be perform some initialize operations

This sounds like a "change control" to me, a one-time change when you release. We support these as well but not in the free version unfortunately.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜