Files

25 lines
967 B
PowerShell

param([string]$ProjectPath);
# Gestione calcolata numero Versione del componente: Major/Minor da gestire a mano, Rel e Build ricalcolate in compilazione
echo "Modifica dati versione pacchetto nuget"
$fileContent = Get-Content $ProjectPath -Raw;
$pattern = '(?i)<Version>\s*(.*?)\s*</Version>'
$vers = if ($fileContent -match $pattern) { $matches[1] } else { $null }
echo "Versione corrente: $vers"
# calcolo Rel e Build...
$Release = (Get-Date).Month;
$Build = get-date -format dHH;
$parts = $vers -split '\.'
#$newVers = "$parts[0].$parts[1].$Release.$Build"
$newParts = @($parts[0], $parts[1], $Release, $Build)
$newVers = $newParts -join '.'
echo "Versione calcolata: $newVers"
$findVers = "<Version>(.|\n)*?</Version>";
$replVers = "<Version>" + $newVers + "</Version>";
$newContent = $fileContent -replace $findVers, $replVers;
Set-Content -Path $ProjectPath -Value $newContent;
echo "Modifica dati file progetto x nuspec completata su file $ProjectPath"