fix: parse version.json instead of version.txt in Program.cs
TaxBaik CI/CD / build-and-deploy (push) Successful in 49s

- CI/CD generates version.json (JSON format) but Program.cs was parsing version.txt
- Update version loading to read from version.json
- Add error handling for JSON parsing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-28 09:57:01 +09:00
parent 821b73fe01
commit 541b04cf3d
+13 -8
View File
@@ -85,16 +85,21 @@ builder.Services.AddApplication();
// Register version info
var versionInfo = new VersionInfo();
var versionFilePath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "version.txt");
if (File.Exists(versionFilePath))
var versionJsonPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "version.json");
if (File.Exists(versionJsonPath))
{
var lines = File.ReadAllLines(versionFilePath);
foreach (var line in lines)
try
{
if (line.StartsWith("Version:"))
versionInfo.Version = line.Substring("Version:".Length).Trim();
else if (line.StartsWith("Built:"))
versionInfo.Built = line.Substring("Built:".Length).Trim();
var json = System.Text.Json.JsonDocument.Parse(File.ReadAllText(versionJsonPath));
var root = json.RootElement;
if (root.TryGetProperty("version", out var versionProp))
versionInfo.Version = versionProp.GetString() ?? "unknown";
if (root.TryGetProperty("built", out var builtProp))
versionInfo.Built = builtProp.GetString() ?? "unknown";
}
catch (Exception ex)
{
Console.WriteLine($"Warning: Failed to parse version.json: {ex.Message}");
}
}
builder.Services.AddSingleton(versionInfo);