Correzione csproj del complex config x pacchetto nuget

This commit is contained in:
Samuele Locatelli
2025-09-12 17:16:18 +02:00
parent 1ae5bc4c3b
commit b1f2b5d478
2 changed files with 32 additions and 0 deletions
+8
View File
@@ -4,6 +4,10 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>2.7.9.1217</Version>
<Authors>Annamaria Sassi</Authors>
<Company>Egalware</Company>
<Description>Componente gestione Configurazioni avanzate Window per LUX</Description>
</PropertyGroup>
@@ -17,5 +21,9 @@
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.19" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\post-build.ps1 -ProjectPath $(ProjectPath)" />
</Target>
</Project>
+24
View File
@@ -0,0 +1,24 @@
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"