forked from ppankiewicz/Emby.SmartPlaylist.Plugin
-
Notifications
You must be signed in to change notification settings - Fork 6
/
update_assembly_ver.ps1
55 lines (45 loc) · 1.38 KB
/
update_assembly_ver.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
function getVersion()
{
$tag = iex "git describe --tags --always"
$a = [regex]"v\d+\.\d+\.\d+\.\d+"
$b = $a.Match($tag)
$b = $b.Captures[0].value
$b = $b -replace '-', '.'
$b = $b -replace 'v', ''
Write-Host "Version found: $b"
return $b
}
function SetVersion ($file, $version)
{
$splitNumber = $version.Split(".")
$majorNumber = $splitNumber[0]
$minorNumber = $splitNumber[1]
$revisionNumber = $splitNumber[3]
# I need to keep my build number under the 65K int limit, hence this hack of a method
$myBuildNumber = (Get-Date).Year + ((Get-Date).Month * 31) + (Get-Date).Day
$myBuildNumber = $majorNumber + "." + $minorNumber + "." + $myBuildNumber + "." + $revisionNumber
$xml=New-Object XML
$xml.PreserveWhitespace = $true
$xml.Load($file)
$xml.Project.PropertyGroup.AssemblyVersion = $version
$xml.Project.PropertyGroup.FileVersion = $version
$xml.Save($file)
Write-Host "Updated csproj "$file" and set to version "$version
}
function setVersionInDir($dir, $version) {
if ($version -eq "") {
Write-Host "version not found"
exit 1
}
# Set the Assembly version
$info_files = Get-ChildItem $dir -Recurse -Include "SmartPlaylist.csproj"
foreach($file in $info_files)
{
Setversion $file $version
}
}
# First get tag from Git
$version = getVersion
$dir = "./"
setVersionInDir $dir $version
return $version