Skip to content

Instantly share code, notes, and snippets.

@rasmuseeg
Created April 17, 2019 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rasmuseeg/f037fa631724530487f4497120a73d24 to your computer and use it in GitHub Desktop.
Save rasmuseeg/f037fa631724530487f4497120a73d24 to your computer and use it in GitHub Desktop.
Increment clientdependency.config version during continues deployment
param(
[Parameter(Position=0,
HelpMessage="Path to your project.")]
[ValidateNotNullOrEmpty()]
[string]
$ProjectPath = "..\DanskBilglas.UmbracoCMS\Config\",
[Parameter(Position=1,
HelpMessage="Name of your client dependency config (default: ClientDependency.config)")]
[string]
$FileName = 'ClientDependency.config',
# Parameter help description
[Parameter(Mandatory=$true, Position=2)]
[bool]
$CommitAndPush = $false
)
$returnLocation = (Get-Location).Path;
Set-Location -Path $ProjectPath
$filePath = "$FileName";
$xdoc = [System.Xml.XmlDocument](Get-Content "$filePath");
$clientDependencyNode = $xdoc.SelectSingleNode('clientDependency');
[string]$strVersion = $clientDependencyNode.GetAttribute('version');
[int]$version = [convert]::ToInt32($strVersion);
$version = $version + 1;
$clientDependencyNode.SetAttribute('version', $version);
$savePath = (Get-Location).Path + "\$filePath";
$xdoc.Save($savePath)
if($CommitAndPush -eq $true)
{
git add $filePath
git commit -m "Incremented ClientDependency Version: $version";
git push
}
Set-Location -Path $returnLocation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment