Checkers-Drafts Game: An Azure Deployment Issue
ai drafts checkers blazor azure azuewebservice
Just had an interesting problem with deployment of Blazor app to Azure wrt project Version.
The Problem
In project file have:
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Version>7.0.0</Version>
<Nullable>enable</Nullable>
On first page have:
<PageTitleHeading Title="@($"Checkers online V{Version}")" HeadingLevel="2" />
Version is a project property.
Was originally getting using:
private string Version
{
get
{
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "Unknown";
var parts = version.Split('.');
if (parts.Length >= 3)
return $"{parts[0]}.{parts[1]}.{parts[2]}";
return version;
}
}
That worked locally but kept returning earlier version number on Azure after deployment. New functionality in the project’s app worked despite that. Tried refreshing, waiting for cache to clear but alas no fix.
The Solution
Was suggested that would be simper to hard code in property but a but a better solution was proposed:
Solution: Already had a json file in app for seed values for the app’s database. So added version to json file:
{
"version": "7.0.0",
"exportDate": "2026-03-16T03:26:12.0962439Z",
"users": [
New property code:
private string Version
{
get
{
try
{
// Read version from auth.json
var jsonPath = Path.Combine(Directory.GetCurrentDirectory(), "auth.json");
if (File.Exists(jsonPath))
{
var jsonContent = File.ReadAllText(jsonPath);
using var document = JsonDocument.Parse(jsonContent);
if (document.RootElement.TryGetProperty("version", out var versionElement))
{
return versionElement.GetString() ?? "7.0.0";
}
}
}
catch
{
// Fallback if JSON reading fails
}
return "7.0.0"; // Fallback version
}
}
That worked! 😊 This means that if the version details are used elsewhere on the page, there is only one source of it. Could also write it as update to the database.
Additional Notes
Ps Could have done similarly in xml file etc as well, not tested.
Tags: #Azure #Blazor #Deployment #Version #Debugging
| Topic | Subtopic | |
| Next: > | Checkers-Drafts Game | AI App Dev Style |
| This Category Links | ||
| Category: | Artificial Intelligence Index: | Artificial Intelligence |
| < Prev: | Checkers-Drafts Game | Working documents |