-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUpdateNuspecVersion.ps1
34 lines (28 loc) · 1.12 KB
/
UpdateNuspecVersion.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
Param([string]$preRelease,[string]$major,[string]$minor)
$children = gci ./ -recurse *.nuspec
foreach( $child in $children)
{
$nuspecFile = gi $child.fullName
[xml] $content = Get-Content $nuspecFile
$end = Get-Date
$end = $end.ToUniversalTime()
$start = Get-Date "12/1/2016"
$today = Get-Date
$today = $today.ToUniversalTime()
$today = $today.ToShortDateString()
$today = Get-Date $today
$versionPart = $content.package.metadata.version.Split('.')
$revisionNumber = New-TimeSpan -Start $start -End $end
$minutes = New-TimeSpan -Start $today -End $end
$buildNumber = [math]::Round($minutes.TotalMinutes)
if(!$major) {$major = $versionPart[0]}
if(!$minor) {$minor = $versionPart[1]}
if($preRelease){
$content.package.metadata.version = $major +"." + $minor + "." + $revisionNumber.Days + "-$preRelease" + ("{0:00000}" -f $buildNumber)
}
else{
$content.package.metadata.version = $major +"." + $minor + ".0"
}
Write-Output $child.fullName + "Setting nuget package version: " + $content.package.metadata.version
$content.Save($child.FullName)
}