[Supplement] use a regular expression to change the version number.

Source: Internet
Author: User
1 String Filecontents = Readfile (fname );
2 Rgx =   New RegEx (pattern );
3
4 {
5 Switch (Verarg. length)
6 {
7 Case   4 : // <Major version>. <minor version>. <build number>. <revision>
8 Replacement = String. Format ( " ${4 }}{ 0 }$ {5 }}{ 1 }$ {6 }}{ 2 }$ {7 }}{ 3} " , Verarg );
9 Break ;
10 Case   3 :
11 Replacement = String. Format ( " ${3 }}{ 0 }$ {4 }}{ 1 }$ {5 }}{ 2} " , Verarg );
12 Break ;
13 Case   2 :
14 Replacement = String. Format ( " ${2 }}{ 0 }$ {3 }}{ 1} " , Verarg );
15 Break ;
16 Case   1 :
17 Replacement = String. Format ( " ${1 }}{ 0} " , Verarg );
18 Break ;
19 }
20 }
21
22   // Replace the build component of the assemblyversion attribute
23 // With the specified build number.
24 Filecontents = Rgx. Replace (filecontents, replacement );
25
26 // Reversion ++
27 If (Configurationmanager. deleettings [ " Autoreversion " ] =   " True " )
28 {
29 // Read rows in matching mode
30 Match matchline = Rgx. Match (filecontents );
31 String Strline = Filecontents. substring (matchline. Groups [ 0 ]. Index );
32 Strline = Strline. substring ( 0 , Strline. indexof ( " \ R \ n " ));
33
34 // Match Four versions
35 RegEx =   New RegEx ( @" (? <Major> [0-9] +) \ s * [\.,] \ s *(? <Minor> [0-9] +) \ s * [\.,] \ s *(? <Build> [0-9] +) \ s * [\.,] \ s *(? <Revision> [0-9] +) " );
36 Match m = RegEx. Match (strline );
37
38 // Get Revision
39 String Strrevision = M. Groups [ " Revision " ]. Value;
40 String Strlinenew = Strline. substring ( 0 , M. Groups [ " Revision " ]. Index );
41 Strlinenew + = ( Int . Parse (strrevision) +   1 );
42
43 // Update the compilation sequence number
44 Filecontents = Filecontents. Replace (strline, strlinenew );
45
46 }
47 // Open assemblyversioninfo file for write access
48 // Note: filemode. truncate extends tively deletes the contents
49 // Of the file.
50 Writefile (fname, filecontents, True );

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.