2 Commits

3 changed files with 37 additions and 8 deletions
+8
View File
@@ -5,6 +5,8 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<!-- Version is now automatically calculated by MinVer from git tags --> <!-- Version is now automatically calculated by MinVer from git tags -->
<MinVerTagPrefix>v</MinVerTagPrefix>
<MinVerVerbosity>detailed</MinVerVerbosity>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -27,4 +29,10 @@
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Update="wwwroot\version.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project> </Project>
+26 -5
View File
@@ -43,10 +43,30 @@ namespace Data_Coupler.Services
{ {
try try
{ {
// Cerca il file version.json nella root dell'applicazione // Cerca il file version.json nella cartella wwwroot o nella root del progetto
var versionFilePath = Path.Combine(_env.ContentRootPath, "version.json"); string? versionFilePath = null;
// Prima prova in wwwroot
if (!string.IsNullOrEmpty(_env.WebRootPath))
{
var wwwrootPath = Path.Combine(_env.WebRootPath, "version.json");
if (File.Exists(wwwrootPath))
{
versionFilePath = wwwrootPath;
}
}
// Se non trovato, prova nella root del progetto
if (versionFilePath == null)
{
var contentPath = Path.Combine(_env.ContentRootPath, "wwwroot", "version.json");
if (File.Exists(contentPath))
{
versionFilePath = contentPath;
}
}
if (File.Exists(versionFilePath)) if (versionFilePath != null && File.Exists(versionFilePath))
{ {
var json = File.ReadAllText(versionFilePath); var json = File.ReadAllText(versionFilePath);
var version = JsonSerializer.Deserialize<VersionInfo>(json, new JsonSerializerOptions var version = JsonSerializer.Deserialize<VersionInfo>(json, new JsonSerializerOptions
@@ -56,13 +76,14 @@ namespace Data_Coupler.Services
if (version != null) if (version != null)
{ {
_logger.LogInformation("Version loaded: {Version}", version.GetFullVersion()); _logger.LogInformation("Version loaded from {Path}: {Version}", versionFilePath, version.GetFullVersion());
return version; return version;
} }
} }
else else
{ {
_logger.LogWarning("version.json not found at {Path}, using default version", versionFilePath); _logger.LogWarning("version.json not found. Searched in WebRootPath: {WebRoot}, ContentRootPath: {ContentRoot}",
_env.WebRootPath ?? "null", _env.ContentRootPath);
} }
} }
catch (Exception ex) catch (Exception ex)
+3 -3
View File
@@ -1,7 +1,7 @@
{ {
"version": "2.1.0", "version": "2.1.2",
"commitSha": "local", "commitSha": "593c0b6",
"branch": "dev", "branch": "development",
"buildDate": "2026-02-02", "buildDate": "2026-02-02",
"buildEnvironment": "Local" "buildEnvironment": "Local"
} }