Skip to content

Commit

Permalink
Merge pull request #766 from santhoshb-msft/main
Browse files Browse the repository at this point in the history
Simplified logic to show three part version, removing the revision
  • Loading branch information
santhoshb-msft authored Oct 3, 2024
2 parents 97978e9 + edd53ff commit 3658c32
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
9 changes: 3 additions & 6 deletions src/AdminSite/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,11 @@ public void ConfigureServices(IServiceCollection services)
.AddSingleton<SaaSApiClientConfiguration>(config)
.AddSingleton<KnownUsersModel>(knownUsers);

// Read the versionInfo and Add to services
var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
services.AddSingleton<IAppVersionService>(new AppVersionService(versionInfo));

// Add the assembly version
services.AddSingleton<IAppVersionService>(new AppVersionService(Assembly.GetExecutingAssembly()?.GetName()?.Version));

services
.AddScoped<ApplicationConfigService>()
;
.AddScoped<ApplicationConfigService>();

services
.AddDbContext<SaasKitContext>(options => options.UseSqlServer(this.Configuration.GetConnectionString("DefaultConnection")));
Expand Down
5 changes: 2 additions & 3 deletions src/CustomerSite/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ public void ConfigureServices(IServiceCollection services)
.AddSingleton<SaaSApiClientConfiguration>(config)
.AddSingleton<ValidateJwtToken>();

// Read the versionInfo and Add to services
var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
services.AddSingleton<IAppVersionService>(new AppVersionService(versionInfo));
// Add the assembly version
services.AddSingleton<IAppVersionService>(new AppVersionService(Assembly.GetExecutingAssembly()?.GetName()?.Version));

services
.AddDbContext<SaasKitContext>(options => options.UseSqlServer(this.Configuration.GetConnectionString("DefaultConnection")));
Expand Down
7 changes: 0 additions & 7 deletions src/Services/Contracts/IAppVersionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,4 @@ namespace Marketplace.SaaS.Accelerator.Services.Services;
public interface IAppVersionService
{
string Version { get; }

int? ProductMajorPart { get; }

int? ProductMinorPart { get; }

int? ProductBuildPart { get; }

}
25 changes: 12 additions & 13 deletions src/Services/Services/AppVersionService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
Expand All @@ -13,20 +14,18 @@ public class AppVersionService : IAppVersionService

public string Version { get; }

public int? ProductMajorPart { get; }

public int? ProductMinorPart { get; }

public int? ProductBuildPart { get; }

/// <summary>
/// Sets the Application Version.
/// </summary>
public AppVersionService(FileVersionInfo version)
public AppVersionService(Version version)
{
Version = version.ProductVersion;
ProductMajorPart = version.ProductMajorPart;
ProductMinorPart = version.ProductMinorPart;
ProductBuildPart = version.ProductBuildPart;
if (version != null)
{
Version = $"{version?.Major}.{version?.Minor}.{version?.Build}";
}
else
{
Version = "1.0.0";
}
}
}
}

0 comments on commit 3658c32

Please sign in to comment.