-
Notifications
You must be signed in to change notification settings - Fork 0
/
modMian.vb
86 lines (77 loc) · 3.5 KB
/
modMian.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Imports System.IO
Imports System.Text
Module modMian
Sub Main()
Try
If My.Application.CommandLineArgs.Count <> 1 Then
Throw New Exception("Invalid Agreement.")
End If
'Dim rs As New FileStream(My.Application.CommandLineArgs(0), FileMode.Open, FileAccess.ReadWrite, FileShare.Read)
Dim rs As New StreamReader(My.Application.CommandLineArgs(0), True)
Dim newcontent As New StringBuilder
While Not rs.EndOfStream
Dim strline As String = rs.ReadLine
If strline.StartsWith("<Assembly: AssemblyVersion") Then
Dim strVer As String = strline.Split("""")(1)
Dim arrVer() As String = strVer.Split(".")
'修订号 自增
If CInt(arrVer(3)) = 8000 Then
arrVer(3) = "0"
arrVer(2) = CInt(arrVer(2)) + 1
'生成号 自增
If CInt(arrVer(2)) = 99 Then
arrVer(2) = "0"
arrVer(1) = CInt(arrVer(1)) + 1
'次版本号自增
If CInt(arrVer(1)) = 9 Then
arrVer(1) = "0"
arrVer(0) = CInt(arrVer(0)) + 1
Else
arrVer(1) = CInt(arrVer(1)) + 1
End If
Else
arrVer(2) = CInt(arrVer(2)) + 1
End If
Else
arrVer(3) = CInt(arrVer(3)) + 1
End If
strline = strline.Replace(strVer, arrVer(0) & "." & arrVer(1) & "." & arrVer(2) & "." & arrVer(3))
End If
If strline.StartsWith("<Assembly: AssemblyFileVersion") Then
Dim strFileVer As String = strline.Split("""")(1)
Dim arrVer() As String = strFileVer.Split(".")
'修订号 自增
If CInt(arrVer(3)) = 8000 Then
arrVer(3) = "0"
arrVer(2) = CInt(arrVer(2)) + 1
'生成号 自增
If CInt(arrVer(2)) = 99 Then
arrVer(2) = "0"
arrVer(1) = CInt(arrVer(1)) + 1
'次版本号自增
If CInt(arrVer(1)) = 9 Then
arrVer(1) = "0"
arrVer(0) = CInt(arrVer(0)) + 1
Else
arrVer(1) = CInt(arrVer(1)) + 1
End If
Else
arrVer(2) = CInt(arrVer(2)) + 1
End If
Else
arrVer(3) = CInt(arrVer(3)) + 1
End If
strline = strline.Replace(strFileVer, arrVer(0) & "." & arrVer(1) & "." & arrVer(2) & "." & arrVer(3))
End If
newcontent.AppendLine(strline)
End While
rs.Close()
Dim ws As New StreamWriter(My.Application.CommandLineArgs(0), False)
ws.WriteLine(newcontent.ToString)
ws.Close()
Catch ex As Exception
'Console.Write(ex.Message)
End Try
'Console.ReadKey()
End Sub
End Module