-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet-NuGetVersion.ps1
More file actions
50 lines (41 loc) · 1.33 KB
/
Set-NuGetVersion.ps1
File metadata and controls
50 lines (41 loc) · 1.33 KB
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
# Set-AssemblyVersion.ps1
#
# Set the version in all the AssemblyInfo.cs files in any subdirectory.
#
# usage:
# from cmd.exe:
# powershell.exe Set-AssemblyVersion.ps1 2.8.3.0 C:\Temp
#
# from powershell.exe prompt:
# .\Set-AssemblyVersion.ps1 2.8.3.0 C:\Temp
#
# powershell .\Set-NuGetVersion.ps1 -versionPrefix ${bamboo.versionPrefix} -buildNumber ${bamboo.buildNumber} -revisionNumber ${bamboo.repository.revision.number}
function Usage
{
Write-Host "Usage: ";
Write-Host " from cmd.exe: ";
Write-Host " powershell.exe Set-NuGetVersion.ps1 2.8.3.0 C:\Temp\package.nuspec";
Write-Host " ";
Write-Host " from powershell.exe prompt: ";
Write-Host " .\Set-NuGetVersion.ps1 2.8.3.0 C:\Temp\package.nuspec";
Write-Host " ";
}
function Update-AllAssemblyInfoFiles ([string] $Version, [string] $FileFullPath )
{
$NewVersion = '<version>' + $Version + '</version>'
$TmpFile = $FileFullPath + ".tmp"
$TmpFile = $FileFullPath + ".tmp"
get-content $FileFullPath | %{$_ -replace "<version>.*<\/version>", $NewVersion } > $TmpFile
move-item $TmpFile $FileFullPath -force
}
# validate arguments
$r= [System.Text.RegularExpressions.Regex]::Match($args[0], "^[0-9]+(\.[0-9]+){1,3}$");
if ($r.Success)
{
Update-AllAssemblyInfoFiles $args[0] $args[1];
}
else
{
Usage ;
throw "Error: Bad Input!"
}