[Fix] Corretto sistema di versioning per container Docker

- Disabilitato target MSBuild GenerateVersionJson durante build CI/CD

- Aggiunta condizione: non esegue se ContinuousIntegrationBuild=true

- Aggiornato Dockerfile per usare /p:ContinuousIntegrationBuild=true

- Previene sovrascrittura del version.json generato dal workflow Gitea

- Risolve problema: container mostra v1.0.0-dev invece della versione da git tag
This commit is contained in:
Alessio Dal Santo
2026-02-17 14:32:05 +01:00
parent 20ca84e4f7
commit 90c14046d5
2 changed files with 7 additions and 4 deletions
+4 -2
View File
@@ -43,7 +43,9 @@
</ItemGroup>
<!-- Target per generare automaticamente version.json prima del build -->
<Target Name="GenerateVersionJson" BeforeTargets="BeforeBuild;BeforeRebuild">
<!-- SOLO per sviluppo locale, NON in CI/CD (il workflow lo genera prima del Docker build) -->
<Target Name="GenerateVersionJson" BeforeTargets="BeforeBuild;BeforeRebuild"
Condition="'$(ContinuousIntegrationBuild)' != 'true' AND '$(SkipVersionGeneration)' != 'true'">
<!-- Esegui git per ottenere il tag più recente e informazioni commit -->
<Exec Command="git describe --tags --abbrev=0 2>nul" ConsoleToMSBuild="true" IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GitLatestTag" />
@@ -82,7 +84,7 @@
<!-- Scrivi il file version.json -->
<WriteLinesToFile File="wwwroot\version.json" Lines="$(FinalVersionJsonContent)" Overwrite="true" />
<Message Text="Generated version.json with version $(ActualVersion) from git tag" Importance="high" />
<Message Text="Generated version.json with version $(ActualVersion) from git tag (local dev build)" Importance="high" />
</Target>
</Project>
+3 -2
View File
@@ -20,14 +20,15 @@ COPY . .
# Build del progetto principale
WORKDIR "/src/Data_Coupler"
RUN dotnet build "Data_Coupler.csproj" -c Release -o /app/build
RUN dotnet build "Data_Coupler.csproj" -c Release -o /app/build /p:ContinuousIntegrationBuild=true
# Stage 2: Publish
FROM build AS publish
RUN dotnet publish "Data_Coupler.csproj" -c Release -o /app/publish \
/p:SelfContained=false \
/p:PublishTrimmed=false \
/p:PublishSingleFile=false
/p:PublishSingleFile=false \
/p:ContinuousIntegrationBuild=true
# Stage 3: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final