2020-02-27 13:24:26 +00:00
|
|
|
param (
|
2021-08-14 13:01:46 -04:00
|
|
|
[Parameter(Position = 0, mandatory = $true)]
|
2025-09-08 21:07:36 +02:00
|
|
|
[string]$version,
|
|
|
|
|
|
|
|
|
|
[switch]$UpdateAssemblyAndFileVersion
|
2020-02-27 13:24:26 +00:00
|
|
|
)
|
|
|
|
|
|
2020-02-27 13:29:15 +00:00
|
|
|
$root = (Split-Path -parent $PSCommandPath)
|
|
|
|
|
|
|
|
|
|
$projs = Get-ChildItem "$root/../src" -Recurse | Where-Object { $_.extension -eq ".csproj" -and $_.name.IndexOf("Tests") -lt 0 }
|
2020-02-27 13:24:26 +00:00
|
|
|
$projs | ForEach-Object {
|
|
|
|
|
$xml = New-Object XML
|
|
|
|
|
$xml.Load($_.FullName)
|
2024-12-15 10:56:03 +00:00
|
|
|
$xml.Project.PropertyGroup.Version = $version
|
2020-02-27 13:24:26 +00:00
|
|
|
$xml.Save($_.FullName)
|
|
|
|
|
}
|
2021-08-14 13:01:46 -04:00
|
|
|
|
|
|
|
|
$packageProjectPath = "$root/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj"
|
|
|
|
|
$xml = New-Object XML
|
|
|
|
|
$xml.Load($packageProjectPath)
|
|
|
|
|
$xml.Project.PropertyGroup[0].Version = $version
|
2025-09-08 21:07:36 +02:00
|
|
|
|
|
|
|
|
if ($UpdateAssemblyAndFileVersion) {
|
|
|
|
|
# Update AssemblyVersion and FileVersion if the nodes exist, otherwise create them
|
|
|
|
|
if (-not $xml.Project.PropertyGroup[0].AssemblyVersion) {
|
|
|
|
|
$node = $xml.CreateElement("AssemblyVersion")
|
|
|
|
|
$node.InnerText = "$version.0" # add the 4th segment
|
|
|
|
|
$xml.Project.PropertyGroup[0].AppendChild($node) | Out-Null
|
|
|
|
|
} else {
|
|
|
|
|
$xml.Project.PropertyGroup[0].AssemblyVersion = "$version.0"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (-not $xml.Project.PropertyGroup[0].FileVersion) {
|
|
|
|
|
$node = $xml.CreateElement("FileVersion")
|
|
|
|
|
$node.InnerText = "$version.0"
|
|
|
|
|
$xml.Project.PropertyGroup[0].AppendChild($node) | Out-Null
|
|
|
|
|
} else {
|
|
|
|
|
$xml.Project.PropertyGroup[0].FileVersion = "$version.0"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-14 13:01:46 -04:00
|
|
|
$xml.Save($packageProjectPath)
|
|
|
|
|
|
2020-02-27 13:24:26 +00:00
|
|
|
Write-Host $projs.Length
|