[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:
@@ -43,7 +43,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Target per generare automaticamente version.json prima del build -->
|
<!-- 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 -->
|
<!-- Esegui git per ottenere il tag più recente e informazioni commit -->
|
||||||
<Exec Command="git describe --tags --abbrev=0 2>nul" ConsoleToMSBuild="true" IgnoreExitCode="true">
|
<Exec Command="git describe --tags --abbrev=0 2>nul" ConsoleToMSBuild="true" IgnoreExitCode="true">
|
||||||
<Output TaskParameter="ConsoleOutput" PropertyName="GitLatestTag" />
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitLatestTag" />
|
||||||
@@ -82,7 +84,7 @@
|
|||||||
<!-- Scrivi il file version.json -->
|
<!-- Scrivi il file version.json -->
|
||||||
<WriteLinesToFile File="wwwroot\version.json" Lines="$(FinalVersionJsonContent)" Overwrite="true" />
|
<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>
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
+3
-2
@@ -20,14 +20,15 @@ COPY . .
|
|||||||
|
|
||||||
# Build del progetto principale
|
# Build del progetto principale
|
||||||
WORKDIR "/src/Data_Coupler"
|
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
|
# Stage 2: Publish
|
||||||
FROM build AS publish
|
FROM build AS publish
|
||||||
RUN dotnet publish "Data_Coupler.csproj" -c Release -o /app/publish \
|
RUN dotnet publish "Data_Coupler.csproj" -c Release -o /app/publish \
|
||||||
/p:SelfContained=false \
|
/p:SelfContained=false \
|
||||||
/p:PublishTrimmed=false \
|
/p:PublishTrimmed=false \
|
||||||
/p:PublishSingleFile=false
|
/p:PublishSingleFile=false \
|
||||||
|
/p:ContinuousIntegrationBuild=true
|
||||||
|
|
||||||
# Stage 3: Runtime
|
# Stage 3: Runtime
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final
|
||||||
|
|||||||
Reference in New Issue
Block a user