Use powershell to customize Version Control

Source: Internet
Author: User

The following is just a small idea of mine. In medium and large projects, we are all used to using command line to compile our system, for example, Nant compile . net Program , however, if I want to build once, add 1 . net self-contained addition, so you can use powershell to define a version-controlled small script program, Code :

$ Ver = "Ver. cs"  
$ S = [System. Io. File]: readalllines ( $ Ver )
If ( $ S . Length -EQ 2 ){
$ Num = $ S [1]. Remove (0, 28). Remove (7, 3). Split ('.')
$ Sum = $ Num [0] + $ Num [1] + $ Num [2] + $ Num [3]
$ Result = $ Sum - [Int32]
$ R = $ Result + 1
$ Results = $ R . Tostring ();
Write-host current version: $ Results  
$ Build = "[Assembly: assemblyversion ("""
+ $ Results [0] + "."
+ $ Results [1] + "."
+ $ Results [2] + "."  
+ $ Results [3] + ")]"  
$ S = "Using system. reflection ;" , $ Build  
[System. Io. File]: writealllines ( $ Ver , $ S )
}

 

Where,Ver. CSIsC #File, which only contains version control code:

using system. reflection;
[Assembly: assemblyversion ( " 1.0.0.0 " )]


Then, in yourBuildIn batch processing, You can execute this script,Ver. CSIn1.0.0.0Add automatically1Become1.0.0.1Of course, the script can be changed at will, so that you can define that the version you want will automatically grow.

If you have your own version control method, share it. This is just my own idea. I think it is definitely not the best.......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.