File tree 1 file changed +46
-0
lines changed
1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ # from http://blogs.msdn.com/b/dotnetinterop/archive/2008/04/21/powershell-script-to-batch-update-assemblyinfo-cs-with-new-version.aspx
2
+
3
+ function Update-SourceVersion
4
+ {
5
+ Param ([string ]$Version )
6
+ $NewVersion = ' AssemblyVersion("' + $Version + ' ")' ;
7
+ $NewFileVersion = ' AssemblyFileVersion("' + $Version + ' ")' ;
8
+
9
+ foreach ($o in $input )
10
+ {
11
+ Write-output $o.FullName
12
+ $TmpFile = $o.FullName + " .tmp"
13
+
14
+ Get-Content $o.FullName - encoding utf8 |
15
+ % {$_ -replace ' AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)' , $NewVersion } |
16
+ % {$_ -replace ' AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)' , $NewFileVersion } |
17
+ Set-Content $TmpFile - encoding utf8
18
+
19
+ move-item $TmpFile $o.FullName - force
20
+ }
21
+ }
22
+
23
+
24
+ function Update-AllAssemblyInfoFiles ( $version )
25
+ {
26
+ foreach ($file in " AssemblyInfo.cs" , " AssemblyInfo.vb" )
27
+ {
28
+ get-childitem - recurse | ? {$_.Name -eq $file } | Update-SourceVersion $version ;
29
+ }
30
+ }
31
+
32
+
33
+ # validate arguments
34
+ $r = [System.Text.RegularExpressions.Regex ]::Match($args [0 ], " ^[0-9]+(\.[0-9]+){1,3}$" );
35
+
36
+ if ($r.Success )
37
+ {
38
+ Update-AllAssemblyInfoFiles $args [0 ];
39
+ }
40
+ else
41
+ {
42
+ echo " " ;
43
+ echo " Bad Input!"
44
+ echo " " ;
45
+ Usage ;
46
+ }
You can’t perform that action at this time.
0 commit comments