diff --git a/.github/azure-pipeline-webui-ci.yml b/.github/azure-pipeline-webui-ci.yml index 21d9d6ddc..343c9ed8c 100644 --- a/.github/azure-pipeline-webui-ci.yml +++ b/.github/azure-pipeline-webui-ci.yml @@ -51,6 +51,57 @@ jobs: inputs: command: restore projects: $(BuildParameters.RestoreBuildProjects) + # Step 1: Get the version tag from the repository +- script: | + echo "Extracting version from Git tag: $(versionTag)" + VERSION=$(echo $(versionTag) | sed 's/^v//') + echo "VERSION=$VERSION" >> $(Build.ArtifactStagingDirectory)/version.txt + displayName: 'Extract version tag' + +# Step 2: Update AssemblyVersion in Web UI .csproj +- powershell: | + $versionFile = "$(Build.ArtifactStagingDirectory)/version.txt" + $version = Get-Content $versionFile + $version = $version.Trim() + + # Path to your .csproj file (adjust if necessary) + $csprojFile = "$(Build.SourcesDirectory)\LearningHub.Nhs.WebUI\LearningHub.Nhs.WebUI.csproj" + + Write-Host "Updating AssemblyVersion and FileVersion and Version in $csprojFile to $version" + + # Load the .csproj XML file + [xml]$csprojXml = Get-Content -Path $csprojFile + + # Update the AssemblyVersion and FileVersion + $csprojXml.Project.PropertyGroup.AssemblyVersion = $version + $csprojXml.Project.PropertyGroup.FileVersion = $version + $csprojXml.Project.PropertyGroup.Version = $version + + # Save the updated .csproj file + $csprojXml.Save($csprojFile) + displayName: 'Update AssemblyVersion in WebUI .csproj' + # Step 2: Update AssemblyVersion in Admin UI .csproj +- powershell: | + $versionFile = "$(Build.ArtifactStagingDirectory)/version.txt" + $version = Get-Content $versionFile + $version = $version.Trim() + + # Path to your .csproj file (adjust if necessary) + $csprojFile = "$(Build.SourcesDirectory)\AdminUI\LearningHub.Nhs.AdminUI\LearningHub.Nhs.AdminUI.csproj" + + Write-Host "Updating AssemblyVersion and FileVersion and Version in $csprojFile to $version" + + # Load the .csproj XML file + [xml]$csprojXml = Get-Content -Path $csprojFile + + # Update the AssemblyVersion and FileVersion + $csprojXml.Project.PropertyGroup.AssemblyVersion = $version + $csprojXml.Project.PropertyGroup.FileVersion = $version + $csprojXml.Project.PropertyGroup.Version = $version + + # Save the updated .csproj file + $csprojXml.Save($csprojFile) + displayName: 'Update AssemblyVersion in AdminUI .csproj' - task: DotNetCoreCLI@2 displayName: Build inputs: diff --git a/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj b/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj index 3eb1d8323..5be3c7dcf 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj +++ b/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj @@ -1,642 +1,649 @@  - - net6.0 - 31abd8b9-4223-4ff3-896b-a46530c9e15c - /subscriptions/57c55d5f-78c1-4373-a021-ff8357548f51/resourceGroups/LearningHubNhsUk-AdminUI-Prod-RG/providers/microsoft.insights/components/LearningHubNhsUk-AdminUI-Prod - true - true - x64 - + + net6.0 + 1.0.0.0 + 1.0.0.0 + 1.0.0 + 31abd8b9-4223-4ff3-896b-a46530c9e15c + /subscriptions/57c55d5f-78c1-4373-a021-ff8357548f51/resourceGroups/LearningHubNhsUk-AdminUI-Prod-RG/providers/microsoft.insights/components/LearningHubNhsUk-AdminUI-Prod + true + true + x64 + - - - - - - + + + + + + - - - - - - - - - - - - - + + + + - - <_ContentIncludedByDefault Remove="bundleconfig.json" /> - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + <_ContentIncludedByDefault Remove="bundleconfig.json" /> + - - - - - - - - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - Always - - + + + Always + + + + + + + + + - - diff --git a/AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs b/AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs index 5517fa636..99e425d86 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs +++ b/AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs @@ -141,6 +141,7 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur services.AddTransient(); services.AddSingleton(); + services.AddSingleton(); services.AddAuthentication(options => { diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/VersionService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/VersionService.cs new file mode 100644 index 000000000..45361c052 --- /dev/null +++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/VersionService.cs @@ -0,0 +1,18 @@ +namespace LearningHub.Nhs.AdminUI.Services +{ + /// + /// Defines the . + /// + public class VersionService + { + /// + /// The GetVersion. + /// + /// The . + public string GetVersion() + { + var version = typeof(Program).Assembly.GetName().Version; + return $"{version?.Major}.{version?.Minor}.{version?.Build}"; + } + } +} diff --git a/AdminUI/LearningHub.Nhs.AdminUI/ViewComponents/VersionViewComponent.cs b/AdminUI/LearningHub.Nhs.AdminUI/ViewComponents/VersionViewComponent.cs new file mode 100644 index 000000000..db857b6ce --- /dev/null +++ b/AdminUI/LearningHub.Nhs.AdminUI/ViewComponents/VersionViewComponent.cs @@ -0,0 +1,34 @@ +namespace LearningHub.Nhs.AdminUI.ViewComponents +{ + using LearningHub.Nhs.AdminUI.Services; + using Microsoft.AspNetCore.Html; + using Microsoft.AspNetCore.Mvc; + using Microsoft.AspNetCore.Mvc.ViewComponents; + + /// + /// Initializes a new instance of the class. + /// + public class VersionViewComponent : ViewComponent + { + private readonly VersionService versionService; + + /// + /// Initializes a new instance of the class. + /// + /// . + public VersionViewComponent(VersionService versionService) + { + this.versionService = versionService; + } + + /// + /// The Invoke. + /// + /// A representing the result of the synchronous operation. + public IViewComponentResult Invoke() + { + var version = this.versionService.GetVersion(); + return new HtmlContentViewComponentResult(new HtmlString($"")); + } + } +} diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Views/Shared/_Layout.cshtml b/AdminUI/LearningHub.Nhs.AdminUI/Views/Shared/_Layout.cshtml index 3f972659a..658a30add 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/Views/Shared/_Layout.cshtml +++ b/AdminUI/LearningHub.Nhs.AdminUI/Views/Shared/_Layout.cshtml @@ -2,83 +2,83 @@ - - - @ViewData["Title"] - Learning Hub Administration - - - + + + @ViewData["Title"] - Learning Hub Administration + + + - + - - - - - - - - - - @RenderSection("Styles", required: false) - @await Html.PartialAsync("_GoogleAnalytics") - + + + + + + + + + + @RenderSection("Styles", required: false) + @await Html.PartialAsync("_GoogleAnalytics") + - -
- -
- @{ - var mainWidth = IsSectionDefined("SideMenu") ? "col-sm-9 col-lg-9 col-xl-10 pageWithMenu" : "col-sm-12"; - } -
- @if (IsSectionDefined("SideMenu")) - { -
- @RenderSection("SideMenu", required: false) -
- } -
- @RenderBody() -
-
-
-
-
- -
+ +
+ +
+ @{ + var mainWidth = IsSectionDefined("SideMenu") ? "col-sm-9 col-lg-9 col-xl-10 pageWithMenu" : "col-sm-12"; + } +
+ @if (IsSectionDefined("SideMenu")) + { +
+ @RenderSection("SideMenu", required: false) +
+ } +
+ @RenderBody() +
+
+
+
+
+ +
- - - - - - - - - - @**@ - - @**@ - - @RenderSection("Scripts", required: false) + + + + + + + + + + @**@ + + @**@ + + @RenderSection("Scripts", required: false) - \ No newline at end of file +@await Component.InvokeAsync("Version") diff --git a/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj b/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj index b67f9ae90..29542a834 100644 --- a/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj +++ b/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj @@ -2,11 +2,14 @@ net6.0 - InProcess + 1.0.0.0 + 1.0.0.0 + 1.0.0 + InProcess a2ecb5d2-cf13-4551-9cb6-3d86dfbcf8ef true true - x64 + x64 true @@ -104,7 +107,7 @@ - + @@ -175,72 +178,76 @@ - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + - + + + + + diff --git a/LearningHub.Nhs.WebUI/ServiceCollectionExtension.cs b/LearningHub.Nhs.WebUI/ServiceCollectionExtension.cs index dad5f5001..f38503701 100644 --- a/LearningHub.Nhs.WebUI/ServiceCollectionExtension.cs +++ b/LearningHub.Nhs.WebUI/ServiceCollectionExtension.cs @@ -10,6 +10,7 @@ using LearningHub.Nhs.WebUI.Configuration; using LearningHub.Nhs.WebUI.EventSource; using LearningHub.Nhs.WebUI.Handlers; + using LearningHub.Nhs.WebUI.Services; using LearningHub.Nhs.WebUI.Startup; using Microsoft.ApplicationInsights.Extensibility.EventCounterCollector; using Microsoft.AspNetCore.Builder; @@ -88,6 +89,7 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur .Get(); services.AddTransient(); services.AddSingleton(); + services.AddSingleton(); services.ConfigureAuthentication(learningHubAuthSvcConf); diff --git a/LearningHub.Nhs.WebUI/Services/VersionService.cs b/LearningHub.Nhs.WebUI/Services/VersionService.cs new file mode 100644 index 000000000..b7f170a88 --- /dev/null +++ b/LearningHub.Nhs.WebUI/Services/VersionService.cs @@ -0,0 +1,18 @@ +namespace LearningHub.Nhs.WebUI.Services +{ + /// + /// Defines the . + /// + public class VersionService + { + /// + /// The GetVersion. + /// + /// The . + public string GetVersion() + { + var version = typeof(Program).Assembly.GetName().Version; + return $"{version?.Major}.{version?.Minor}.{version?.Build}"; + } + } +} diff --git a/LearningHub.Nhs.WebUI/ViewComponents/VersionViewComponent.cs b/LearningHub.Nhs.WebUI/ViewComponents/VersionViewComponent.cs new file mode 100644 index 000000000..2f119c184 --- /dev/null +++ b/LearningHub.Nhs.WebUI/ViewComponents/VersionViewComponent.cs @@ -0,0 +1,34 @@ +namespace LearningHub.Nhs.WebUI.ViewComponents +{ + using LearningHub.Nhs.WebUI.Services; + using Microsoft.AspNetCore.Html; + using Microsoft.AspNetCore.Mvc; + using Microsoft.AspNetCore.Mvc.ViewComponents; + + /// + /// Initializes a new instance of the class. + /// + public class VersionViewComponent : ViewComponent + { + private readonly VersionService versionService; + + /// + /// Initializes a new instance of the class. + /// + /// . + public VersionViewComponent(VersionService versionService) + { + this.versionService = versionService; + } + + /// + /// The Invoke. + /// + /// A representing the result of the synchronous operation. + public IViewComponentResult Invoke() + { + var version = this.versionService.GetVersion(); + return new HtmlContentViewComponentResult(new HtmlString($"")); + } + } +} \ No newline at end of file diff --git a/LearningHub.Nhs.WebUI/Views/Shared/Tenant/LearningHub/_Layout.cshtml b/LearningHub.Nhs.WebUI/Views/Shared/Tenant/LearningHub/_Layout.cshtml index 9127802e9..31b0e07a5 100644 --- a/LearningHub.Nhs.WebUI/Views/Shared/Tenant/LearningHub/_Layout.cshtml +++ b/LearningHub.Nhs.WebUI/Views/Shared/Tenant/LearningHub/_Layout.cshtml @@ -153,11 +153,12 @@ @RenderSection("Scripts", required: false) + - +@await Component.InvokeAsync("Version") @functions { public async Task DisplayOffline() { diff --git a/ReportAPI/LearningHub.Nhs.ReportApi/LearningHub.Nhs.ReportApi.csproj b/ReportAPI/LearningHub.Nhs.ReportApi/LearningHub.Nhs.ReportApi.csproj index 24bfc4239..959a3e17f 100644 --- a/ReportAPI/LearningHub.Nhs.ReportApi/LearningHub.Nhs.ReportApi.csproj +++ b/ReportAPI/LearningHub.Nhs.ReportApi/LearningHub.Nhs.ReportApi.csproj @@ -1,47 +1,50 @@  - - net6.0 - enable - enable - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - - - + + net6.0 + 1.0.0.0 + 1.0.0.0 + 1.0.0 + enable + enable + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + + + diff --git a/ReportAPI/LearningHub.Nhs.ReportApi/ServiceCollectionExtension.cs b/ReportAPI/LearningHub.Nhs.ReportApi/ServiceCollectionExtension.cs index 82f3fbf0e..d01574338 100644 --- a/ReportAPI/LearningHub.Nhs.ReportApi/ServiceCollectionExtension.cs +++ b/ReportAPI/LearningHub.Nhs.ReportApi/ServiceCollectionExtension.cs @@ -39,11 +39,13 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur var swaggerTitle = configuration["Swagger:Title"]; var swaggerVersion = configuration["Swagger:Version"]; - var swaggerDescription = $"Build Number: {configuration["Swagger:BuildNumber"]}"; + var swaggerDescription = "This is the API documentation for version "; services.AddSwaggerGen(c => { - c.SwaggerDoc(swaggerTitle, new OpenApiInfo { Title = swaggerTitle, Version = swaggerVersion, Description = swaggerDescription }); + var version = typeof(Program).Assembly.GetName().Version; + var versionString = $"{version?.Major}.{version?.Minor}.{version?.Build}"; + c.SwaggerDoc(swaggerTitle, new OpenApiInfo { Title = swaggerTitle, Version = swaggerVersion, Description = $"{swaggerDescription}{versionString}" }); c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, $"{Assembly.GetExecutingAssembly().GetName().Name}.XML")); c.CustomSchemaIds(type => type.ToString()); }); diff --git a/WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj b/WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj index 86a1a5dd3..6ffba9df6 100644 --- a/WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj +++ b/WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj @@ -1,63 +1,70 @@  - - net6.0 - InProcess - 234b55ad-984b-47ae-9d7a-71e372e6ded7 - true - x64 - - - - LearningHub.Nhs.Api.xml - - - - - - - - - Always - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - + + net6.0 + 1.0.0.0 + 1.0.0.0 + 1.0.0 + InProcess + 234b55ad-984b-47ae-9d7a-71e372e6ded7 + true + x64 + + + + LearningHub.Nhs.Api.xml + + + + + + + + + Always + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WebAPI/LearningHub.Nhs.API/ServiceCollectionExtension.cs b/WebAPI/LearningHub.Nhs.API/ServiceCollectionExtension.cs index 528533f0d..9c8229639 100644 --- a/WebAPI/LearningHub.Nhs.API/ServiceCollectionExtension.cs +++ b/WebAPI/LearningHub.Nhs.API/ServiceCollectionExtension.cs @@ -64,11 +64,12 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur var swaggerTitle = configuration["Swagger:Title"]; var swaggerVersion = configuration["Swagger:Version"]; - var swaggerDescription = $"Build Number: {configuration["Swagger:BuildNumber"]}"; - + var swaggerDescription = "This is the API documentation for version "; services.AddSwaggerGen(c => { - c.SwaggerDoc(swaggerTitle, new OpenApiInfo { Title = swaggerTitle, Version = swaggerVersion, Description = swaggerDescription }); + var version = typeof(Program).Assembly.GetName().Version; + var versionString = $"{version?.Major}.{version?.Minor}.{version?.Build}"; + c.SwaggerDoc(swaggerTitle, new OpenApiInfo { Title = swaggerTitle, Version = swaggerVersion, Description = $"{swaggerDescription}{versionString}" }); c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, $"{Assembly.GetExecutingAssembly().GetName().Name}.XML")); c.CustomSchemaIds(type => type.ToString()); });