forked from IdeaBlade/Punch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateVersion.ps1
37 lines (30 loc) · 1.25 KB
/
UpdateVersion.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
param($version)
if (!$version)
{
Write-Host "Error: Must specify a version!" -foregroundcolor red
}
else
{
$assemblyVersion = $version.Split("-")[0] # Remove pre-release part
# Update version in AssemblyInfo.cs
foreach ($file in dir -Path .\ -Filter "AssemblyInfo.cs" -Recurse | ? { !($_.FullName -match "\\Samples\\") })
{
$content = [IO.File]::ReadAllText($file.FullName)
$content = $content -replace "\[assembly: AssemblyVersion\("".*?""\)\]", "[assembly: AssemblyVersion(""$assemblyVersion"")]"
$content = $content -replace "\[assembly: AssemblyFileVersion\("".*?""\)\]", "[assembly: AssemblyFileVersion(""$assemblyVersion"")]"
[IO.File]::WriteAllText($file.FullName, $content)
}
# Update version in NuGet packages
foreach ($file in dir -Path ./NuGet/*.nuspec)
{
[xml] $nuspec = Get-Content -Path $file.FullName
# Update package version
$nuspec.package.metadata.version = $version
# Update dependencies
foreach ($d in $nuspec.package.metadata.dependencies.dependency | ? { $_.id -match "IdeaBlade.Cocktail" -and $_.version})
{
$d.version = "[$version]"
}
$nuspec.Save($file.FullName)
}
}