Aggiornamento staging #11
@@ -29,4 +29,10 @@
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="wwwroot\version.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -43,10 +43,30 @@ namespace Data_Coupler.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
// Cerca il file version.json nella root dell'applicazione
|
||||
var versionFilePath = Path.Combine(_env.ContentRootPath, "version.json");
|
||||
// Cerca il file version.json nella cartella wwwroot o nella root del progetto
|
||||
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 version = JsonSerializer.Deserialize<VersionInfo>(json, new JsonSerializerOptions
|
||||
@@ -56,13 +76,14 @@ namespace Data_Coupler.Services
|
||||
|
||||
if (version != null)
|
||||
{
|
||||
_logger.LogInformation("Version loaded: {Version}", version.GetFullVersion());
|
||||
_logger.LogInformation("Version loaded from {Path}: {Version}", versionFilePath, version.GetFullVersion());
|
||||
return version;
|
||||
}
|
||||
}
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user