forked from Knight1988/BigBlueButtonApi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetVersion.ps1
90 lines (75 loc) · 2.02 KB
/
SetVersion.ps1
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
87
88
89
90
# SetVersion.ps1
#
# Set the version in all the AssemblyInfo.cs or AssemblyInfo.vb files in any subdirectory.
#
# usage:
# from cmd.exe:
# powershell.exe SetVersion.ps1 2.8.3.0
#
# from powershell.exe prompt:
# .\SetVersion.ps1 2.8.3.0
#
# last saved Time-stamp: <Wednesday, April 23, 2008 11:52:15 (by dinoch)>
#
function Usage
{
echo "Usage: ";
echo " from cmd.exe: ";
echo " powershell.exe SetVersion.ps1 2.8.3.0";
echo " ";
echo " from powershell.exe prompt: ";
echo " .\SetVersion.ps1 2.8.3.0";
echo " ";
}
function Update-SourceVersion
{
Param ([string]$Version)
$NewVersion = 'AssemblyVersion("' + $Version + '")';
$NewFileVersion = 'AssemblyFileVersion("' + $Version + '")';
foreach ($o in $input)
{
Write-output $o.FullName
$TmpFile = $o.FullName + ".tmp"
get-content $o.FullName |
%{$_ -replace 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewVersion } |
%{$_ -replace 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewFileVersion } > $TmpFile
move-item $TmpFile $o.FullName -force
}
}
function Update-NuspecVersion
{
Param ([string]$Version)
$NewVersion = '<version>' + $Version + '</version>';
foreach ($o in $input)
{
Write-output $o.FullName
$TmpFile = $o.FullName + ".tmp"
get-content $o.FullName |
%{$_ -replace '<version>[0-9]+(\.([0-9]+|\*)){1,3}</version>', $NewVersion } > $TmpFile
move-item $TmpFile $o.FullName -force
}
}
function Update-AllAssemblyInfoFiles ( $version )
{
foreach ($file in "AssemblyInfo.cs", "AssemblyInfo.vb" )
{
get-childitem -recurse |? {$_.Name -eq $file} | Update-SourceVersion $version ;
}
foreach ($file in "*.nuspec" )
{
get-childitem -recurse |? {$_.Name -eq $file} | Update-SourceVersion $version ;
}
}
# validate arguments
$r= [System.Text.RegularExpressions.Regex]::Match($args[0], "^[0-9]+(\.[0-9]+){1,3}$");
if ($r.Success)
{
Update-AllAssemblyInfoFiles $args[0];
}
else
{
echo " ";
echo "Bad Input!"
echo " ";
Usage ;
}