- Include root in valid directories

- AppSetting bug fix

- Updated testes with base test class and editor configuration changes

- Created new server and wafer counter tasks json files and pipelines to match
This commit is contained in:
2025-07-29 16:56:09 -07:00
parent 6f52566fc2
commit a427c5648a
49 changed files with 1680 additions and 822 deletions

View File

@ -8,7 +8,7 @@
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"preLaunchTask": "Build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net8.0/OI.Metrology.Server.dll",
"args": [],

5
Server/.vscode/mklink.md vendored Normal file
View File

@ -0,0 +1,5 @@
# mklink
```bash Thu Aug 29 2024 09:47:22 GMT-0700 (Mountain Standard Time)
mklink /J "L:\DevOps\OpenInsight-Metrology-Viewer\OI-Metrology\Server\.vscode\.UserSecrets" "C:\Users\phares\AppData\Roaming\Microsoft\UserSecrets\b0a3891c-b775-422c-80ee-63a2f385045d"
```

View File

@ -1,60 +1,158 @@
{
"version": "2.0.0",
"inputs": [
{
"default": "Development",
"description": "Which ASP Net Core Environment?",
"id": "ASPNETCORE_ENVIRONMENT",
"options": [
"Development",
"Production"
],
"type": "pickString"
},
{
"default": "{AssemblyTitle}",
"description": "What Assembly Title?",
"id": "AssemblyTitle",
"type": "promptString"
},
{
"default": "{Build.BuildId}",
"description": "Which Build BuildId?",
"id": "Build.BuildId",
"type": "promptString"
},
{
"default": "{Build.Reason}",
"description": "Which Build Reason?",
"id": "Build.Reason",
"type": "promptString"
},
{
"default": "{Build.Repository.Id}",
"description": "Which Build Repository Id?",
"id": "Build.Repository.Id",
"type": "promptString"
},
{
"default": "{Build.Repository.Name}",
"description": "Which Build Repository Name?",
"id": "Build.Repository.Name",
"type": "promptString"
},
{
"default": "{Build.SourceVersion}",
"description": "Which Build Source Version?",
"id": "Build.SourceVersion",
"type": "promptString"
},
{
"default": "Debug",
"description": "Which Configuration?",
"id": "Configuration",
"options": [
"Debug",
"Release"
],
"type": "pickString"
},
{
"default": "net8.0",
"description": "Which Core Version?",
"id": "CoreVersion",
"options": [
"net8.0"
],
"type": "pickString"
},
{
"default": "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/MSBuild.exe",
"description": "Which MS Build?",
"id": "MSBuild",
"type": "promptString"
},
{
"default": "https://artifactory.intra.infineon.com/artifactory/api/nuget/ngt-fi-package-main-vir/",
"description": "Which Nuget Source?",
"id": "NugetSource",
"type": "promptString"
},
{
"default": "win-x64",
"description": "Which Runtime?",
"id": "Runtime",
"options": [
"win-x64",
"win-x32",
"linux-x64",
"linux-x32"
],
"type": "pickString"
},
{
"default": "L:/",
"description": "Which System DefaultWorkingDirectory?",
"id": "System.DefaultWorkingDirectory",
"options": [
"L:/",
"D:/",
"C:/"
],
"type": "pickString"
},
{
"default": "v4.8",
"description": "Which Core Target Framework Version?",
"id": "TargetFrameworkVersion",
"options": [
"v4.8"
],
"type": "pickString"
}
],
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/OI.Metrology.Server.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
"build"
],
"problemMatcher": "$msCompile"
"command": "dotnet",
"label": "Build",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"label": "buildTests",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/../Tests/OI.Metrology.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
"${workspaceFolder}/../Tests/OI.Metrology.Tests.csproj"
],
"problemMatcher": "$msCompile"
"command": "dotnet",
"label": "Build Tests",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"label": "testDebug",
"args": [
"test",
"${workspaceFolder}/../Tests/OI.Metrology.Tests.csproj"
],
"command": "dotnet",
"type": "process",
"label": "Test Debug",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"args": [
"test",
"${workspaceFolder}/../Tests/OI.Metrology.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "testRelease",
"command": "dotnet",
"type": "process",
"args": [
"test",
"${workspaceFolder}/../Tests/OI.Metrology.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
"-c",
"Release"
],
"problemMatcher": "$msCompile"
"command": "dotnet",
"label": "Test Release",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"label": "Format",
"command": "dotnet",
"type": "process",
"args": [
"format",
"--report",
@ -64,27 +162,24 @@
"--severity",
"warn"
],
"problemMatcher": "$msCompile"
"command": "dotnet",
"label": "Format",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"label": "Format-Whitespace",
"command": "dotnet",
"type": "process",
"args": [
"format",
"whitespace"
],
"problemMatcher": "$msCompile"
"command": "dotnet",
"label": "Format Whitespace",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/OI.Metrology.Server.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
"--configuration",
"Release",
"--runtime",
@ -93,17 +188,14 @@
"-o",
"D:/web-sites/OI-Metrology/hh-3498d1da-_______-OI-Metrology-Release/Server"
],
"problemMatcher": "$msCompile"
"command": "dotnet",
"label": "Publish",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"label": "Publish AOT",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/OI.Metrology.Server.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
"--configuration",
"Release",
"--runtime",
@ -111,64 +203,217 @@
"-p:PublishAot=true",
"/property:GenerateFullPaths=true"
],
"problemMatcher": "$msCompile"
"command": "dotnet",
"label": "Publish AOT",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"label": "old-watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/OI.Metrology.Server.csproj"
"run"
],
"problemMatcher": "$msCompile"
"command": "dotnet",
"label": "Old Watch",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"--launch-profile",
"http",
"run",
"--project",
"${workspaceFolder}/OI.Metrology.Server.csproj",
"--verbose"
],
"isBackground": true,
"command": "dotnet",
"dependsOn": [
"build"
],
"isBackground": true,
"label": "Watch",
"problemMatcher": {
"fileLocation": "relative",
"pattern": {
"regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$",
"file": 1,
"location": 2,
"severity": 3,
"code": 4,
"message": 5
},
"background": {
"activeOnStart": true,
"beginsPattern": "^.*Shutdown requested.*",
"endsPattern": "^.*Application started.*"
},
"fileLocation": "relative",
"pattern": {
"code": 4,
"file": 1,
"location": 2,
"message": 5,
"regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$",
"severity": 3
}
}
},
"type": "process"
},
{
"label": "File-Folder-Helper AOT s X Server",
"type": "shell",
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe",
"args": [
"s",
"X",
"L:/DevOps/Mesa_FI/OI-Metrology Day-Helper-2024-01-08 L:/DevOps/Mesa_FI/OI-Metrology/Server"
],
"problemMatcher": []
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe",
"label": "File-Folder-Helper AOT s X Server",
"problemMatcher": [],
"type": "shell"
},
{
"command": "echo Assembly Title: ${input:AssemblyTitle} & echo Build Id: ${input:Build.BuildId} & echo Build Reason: ${input:Build.Reason} & echo Repo Id: ${input:Build.Repository.Id} & echo Repo Name: ${input:Build.Repository.Name} & echo Source Version: ${input:Build.SourceVersion} & echo Configuration: ${input:Configuration} & echo Core Version: ${input:CoreVersion} & echo Nuget Source: ${input:NugetSource} & echo Runtime: ${input:Runtime}",
"label": "Echo Check",
"problemMatcher": [],
"type": "shell"
},
{
"command": "dotnet user-secrets init & dotnet user-secrets set BuildNumber ${input:Build.BuildId} & dotnet user-secrets set GitCommit ${input:Build.SourceVersion} & dotnet user-secrets list",
"label": "Server - Safe storage of app secrets",
"problemMatcher": [],
"type": "shell"
},
{
"args": [
"build",
"--configuration",
"${input:Configuration}",
"--source",
"${input:NugetSource}"
],
"command": "dotnet",
"label": "Server - Build",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"args": [
"build",
"${workspaceFolder}/../Tests/OI.Metrology.Tests.csproj",
"--configuration",
"${input:Configuration}",
"--source",
"${input:NugetSource}"
],
"command": "dotnet",
"label": "Tests - Build",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"args": [
"test",
"${workspaceFolder}/../Tests/OI.Metrology.Tests.csproj",
"--configuration",
"${input:Configuration}"
],
"command": "dotnet",
"label": "Tests - Test",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"args": [
"publish",
"--configuration",
"${input:Configuration}",
"--runtime",
"${input:Runtime}",
"--self-contained"
],
"command": "dotnet",
"label": "Server - Publish",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"args": [
"publish",
"--configuration",
"${input:Configuration}",
"--runtime",
"${input:Runtime}",
"-p:PublishAot=true"
],
"command": "dotnet",
"label": "Server - AOT Publish",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"command": "(robocopy /MIR \"bin/${input:Configuration}/${input:CoreVersion}/${input:Runtime}/publish\" \"D:/${input:CoreVersion}/${input:Runtime}/${input:Build.Repository.Name}/${input:Build.BuildId}/${input:Configuration}-${input:AssemblyTitle}\") ^& IF %ERRORLEVEL% LEQ 7 exit 0",
"label": "Copy Files to: D:/",
"problemMatcher": [],
"type": "shell"
},
{
"args": [
"tool",
"restore"
],
"command": "dotnet",
"label": "Tool Restore",
"problemMatcher": [],
"type": "process"
},
{
"args": [
"ReportGenerator",
"-reports:${input:System.DefaultWorkingDirectory}/TestResults/**/coverage.cobertura.xml",
"-targetDir:${input:Build.ArtifactStagingDirectory}/Coverage",
"-reportTypes:Html_Dark"
],
"command": "dotnet",
"label": "Report Generator",
"problemMatcher": [],
"type": "process"
},
{
"args": [
"clean",
"${workspaceFolder}/../Tests/OI.Metrology.Tests.csproj",
"--configuration",
"${input:Configuration}"
],
"command": "dotnet",
"label": "Tests - Clean",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"args": [
"clean",
"--configuration",
"${input:Configuration}"
],
"command": "dotnet",
"label": "Server - Clean",
"problemMatcher": "$msCompile",
"type": "process"
},
{
"args": [
"Server - AOT Publish",
"Tool Restore",
"Report Generator"
],
"command": "echo",
"dependsOn": [
"Echo Check",
"Server - Safe storage of app secrets",
"Server - Build",
"Tests - Build",
"Tests - Test",
"Server - Publish",
"Copy Files to: D:/",
"Tests - Clean",
"Server - Clean"
],
"dependsOrder": "sequence",
"label": "Pipeline",
"problemMatcher": [],
"type": "shell"
}
]
],
"version": "2.0.0"
}

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using OI.Metrology.Server.Models;
using OI.Metrology.Shared.Models.Stateless;
namespace OI.Metrology.Server.ApiControllers;
@ -8,9 +9,9 @@ namespace OI.Metrology.Server.ApiControllers;
public class AppSettingsController : ControllerBase, IAppSettingsController<ActionResult>
{
private readonly IAppSettingsRepository<Models.Binder.AppSettings> _AppSettingsRepository;
private readonly IAppSettingsRepository<AppSettings> _AppSettingsRepository;
public AppSettingsController(IAppSettingsRepository<Models.Binder.AppSettings> AppSettingsRepository) => _AppSettingsRepository = AppSettingsRepository;
public AppSettingsController(IAppSettingsRepository<AppSettings> AppSettingsRepository) => _AppSettingsRepository = AppSettingsRepository;
[HttpGet(nameof(IAppSettingsController<ActionResult>.Action.App))]
public ActionResult GetAppSettings() =>

View File

@ -1,4 +1,5 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace OI.Metrology.Server.Models;
@ -36,8 +37,75 @@ public record AppSettings(string ApiFileShare,
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings);
return result;
}
private static void Verify(AppSettings appSettings)
{
if (string.IsNullOrEmpty(appSettings.Company))
throw new Exception("Company name must have a value!");
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
throw new Exception("Working directory name must have a value!");
}
public static AppSettings Get(IConfigurationRoot configurationRoot)
{
AppSettings result;
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
#pragma warning restore IL3050, IL2026
if (appSettings is null
|| appSettings?.Company is null)
{
List<string> paths = [];
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
{
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
continue;
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
continue;
paths.Add(physicalFileProvider.Root);
}
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}");
}
result = new(appSettings.ApiFileShare,
appSettings.ApiLoggingContentTypes,
appSettings.ApiLoggingPathPrefixes,
appSettings.ApiLogPath,
appSettings.ApiUrl,
appSettings.BuildNumber,
appSettings.Company,
appSettings.ConnectionString,
appSettings.EcCharacterizationSi,
appSettings.EcMesaFileShareCharacterizationSi,
appSettings.EcMesaFileShareMetrologySi,
appSettings.EcMetrologySi,
appSettings.GitCommitSeven,
appSettings.InboundApiAllowedIPList,
appSettings.IqsColumns,
appSettings.IqsFileSegments,
appSettings.IqsKey,
appSettings.IqsRed,
appSettings.IqsYellow,
appSettings.IsDevelopment,
appSettings.IsStaging,
appSettings.MockRoot,
appSettings.MonAResource,
appSettings.MonASite,
appSettings.OpenInsightApplicationProgrammingInterface,
appSettings.TableToPath,
appSettings.URLs,
appSettings.WaferCounterDestinationDirectory,
appSettings.WaferCounterTwoFileSecondsWait,
appSettings.WorkingDirectoryName);
Verify(result);
return result;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(AppSettings))]
public partial class AppSettingsSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -1,2 +0,0 @@
[*.cs]
csharp_preserve_single_line_statements = true

View File

@ -1,148 +0,0 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace OI.Metrology.Server.Models.Binder;
public class AppSettings
{
public string? ApiFileShare { get; set; }
public string? ApiLoggingContentTypes { get; set; }
public string? ApiLoggingPathPrefixes { get; set; }
public string? ApiLogPath { get; set; }
public string? ApiUrl { get; set; }
public string? BuildNumber { get; set; }
public string? Company { get; set; }
public string? ConnectionString { get; set; }
public string? EcCharacterizationSi { get; set; }
public string? EcMesaFileShareCharacterizationSi { get; set; }
public string? EcMesaFileShareMetrologySi { get; set; }
public string? EcMetrologySi { get; set; }
public string? GitCommitSeven { get; set; }
public string? InboundApiAllowedIPList { get; set; }
public string? IqsColumns { get; set; }
public string[]? IqsFileSegments { get; set; }
public string? IqsKey { get; set; }
public string? IqsRed { get; set; }
public string? IqsYellow { get; set; }
public bool? IsDevelopment { get; set; }
public bool? IsStaging { get; set; }
public string? MockRoot { get; set; }
public string? MonAResource { get; set; }
public string? MonASite { get; set; }
public string? OpenInsightApplicationProgrammingInterface { get; set; }
public Dictionary<string, string>? TableToPath { get; set; }
public string? URLs { get; set; }
public string? WaferCounterDestinationDirectory { get; set; }
public int? WaferCounterTwoFileSecondsWait { get; set; }
public string? WorkingDirectoryName { get; set; }
public override string ToString()
{
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
return result;
}
private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings)
{
if (appSettings?.ApiFileShare is null)
{
List<string> paths = new();
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
{
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
continue;
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
continue;
paths.Add(physicalFileProvider.Root);
}
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}");
}
}
private static Models.AppSettings Get(AppSettings? appSettings)
{
Models.AppSettings result;
if (appSettings is null) throw new NullReferenceException(nameof(appSettings));
if (appSettings.ApiFileShare is null) throw new NullReferenceException(nameof(ApiFileShare));
if (appSettings.ApiLoggingContentTypes is null) throw new NullReferenceException(nameof(ApiLoggingContentTypes));
if (appSettings.ApiLoggingPathPrefixes is null) throw new NullReferenceException(nameof(ApiLoggingPathPrefixes));
if (appSettings.ApiLogPath is null) throw new NullReferenceException(nameof(ApiLogPath));
if (appSettings.ApiUrl is null) throw new NullReferenceException(nameof(ApiUrl));
if (appSettings.BuildNumber is null) throw new NullReferenceException(nameof(BuildNumber));
if (appSettings.Company is null) throw new NullReferenceException(nameof(Company));
if (appSettings.ConnectionString is null) throw new NullReferenceException(nameof(ConnectionString));
if (appSettings.EcCharacterizationSi is null) throw new NullReferenceException(nameof(EcCharacterizationSi));
if (appSettings.EcMesaFileShareCharacterizationSi is null) throw new NullReferenceException(nameof(EcMesaFileShareCharacterizationSi));
if (appSettings.EcMesaFileShareMetrologySi is null) throw new NullReferenceException(nameof(EcMesaFileShareMetrologySi));
if (appSettings.EcMetrologySi is null) throw new NullReferenceException(nameof(EcMetrologySi));
if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven));
if (appSettings.InboundApiAllowedIPList is null) throw new NullReferenceException(nameof(InboundApiAllowedIPList));
if (appSettings.IqsColumns is null) throw new NullReferenceException(nameof(IqsColumns));
if (appSettings.IqsFileSegments is null) throw new NullReferenceException(nameof(IqsFileSegments));
if (appSettings.IqsKey is null) throw new NullReferenceException(nameof(IqsKey));
if (appSettings.IqsRed is null) throw new NullReferenceException(nameof(IqsRed));
if (appSettings.IqsYellow is null) throw new NullReferenceException(nameof(IqsYellow));
if (appSettings.IsDevelopment is null) throw new NullReferenceException(nameof(IsDevelopment));
if (appSettings.IsStaging is null) throw new NullReferenceException(nameof(IsStaging));
if (appSettings.MockRoot is null) throw new NullReferenceException(nameof(MockRoot));
if (appSettings.MonAResource is null) throw new NullReferenceException(nameof(MonAResource));
if (appSettings.MonASite is null) throw new NullReferenceException(nameof(MonASite));
if (appSettings.OpenInsightApplicationProgrammingInterface is null) throw new NullReferenceException(nameof(OpenInsightApplicationProgrammingInterface));
if (appSettings.URLs is null) throw new NullReferenceException(nameof(URLs));
if (appSettings.TableToPath is null) throw new NullReferenceException(nameof(TableToPath));
if (appSettings.WaferCounterDestinationDirectory is null) throw new NullReferenceException(nameof(WaferCounterDestinationDirectory));
if (appSettings.WaferCounterTwoFileSecondsWait is null) throw new NullReferenceException(nameof(WaferCounterTwoFileSecondsWait));
if (appSettings.WorkingDirectoryName is null) throw new NullReferenceException(nameof(WorkingDirectoryName));
result = new(
appSettings.ApiFileShare,
appSettings.ApiLoggingContentTypes,
appSettings.ApiLoggingPathPrefixes,
appSettings.ApiLogPath,
appSettings.ApiUrl,
appSettings.BuildNumber,
appSettings.Company,
appSettings.ConnectionString,
appSettings.EcCharacterizationSi,
appSettings.EcMesaFileShareCharacterizationSi,
appSettings.EcMesaFileShareMetrologySi,
appSettings.EcMetrologySi,
appSettings.GitCommitSeven,
appSettings.InboundApiAllowedIPList,
appSettings.IqsColumns,
appSettings.IqsFileSegments,
appSettings.IqsKey,
appSettings.IqsRed,
appSettings.IqsYellow,
appSettings.IsDevelopment.Value,
appSettings.IsStaging.Value,
appSettings.MockRoot,
appSettings.MonAResource,
appSettings.MonASite,
appSettings.OpenInsightApplicationProgrammingInterface,
appSettings.TableToPath,
appSettings.URLs,
appSettings.WaferCounterDestinationDirectory,
appSettings.WaferCounterTwoFileSecondsWait.Value,
appSettings.WorkingDirectoryName);
return result;
}
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
{
Models.AppSettings result;
#pragma warning disable IL3050, IL2026
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
#pragma warning restore IL3050, IL2026
PreVerify(configurationRoot, appSettings);
result = Get(appSettings);
return result;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(AppSettings))]
internal partial class BinderAppSettingsSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -43,7 +43,7 @@ public class Program
(string assemblyName, WebApplicationOptions _) = Get(args);
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args);
_ = webApplicationBuilder.Configuration.AddUserSecrets<Program>();
AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration);
AppSettings appSettings = AppSettings.Get(webApplicationBuilder.Configuration);
if (string.IsNullOrEmpty(appSettings.Company))
throw new Exception("Company name must have a value!");
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
@ -78,7 +78,7 @@ public class Program
_ = webApplicationBuilder.Services.AddSingleton<IServiceShopOrderRepository, ServiceShopOrderRepository>();
_ = webApplicationBuilder.Services.AddSingleton<ISpreadingResistanceProfileService, SpreadingResistanceProfileService>();
_ = webApplicationBuilder.Services.AddSingleton<IDbConnectionFactory, SQLDbConnectionFactory>(_ => sqlDbConnectionFactory);
_ = webApplicationBuilder.Services.AddSingleton<IAppSettingsRepository<Models.Binder.AppSettings>>(_ => appSettingsRepository);
_ = webApplicationBuilder.Services.AddSingleton<IAppSettingsRepository<AppSettings>>(_ => appSettingsRepository);
_ = webApplicationBuilder.Services.AddSwaggerGen();
_ = webApplicationBuilder.Services.AddSession(sessionOptions =>

View File

@ -3,27 +3,20 @@ using OI.Metrology.Shared.Models.Stateless;
namespace OI.Metrology.Server.Repository;
public class AppSettingsRepository : IAppSettingsRepository<Models.Binder.AppSettings>
public class AppSettingsRepository : IAppSettingsRepository<AppSettings>
{
private readonly AppSettings _AppSettings;
public AppSettingsRepository(AppSettings appSettings) => _AppSettings = appSettings;
internal Models.Binder.AppSettings GetAppSettings()
internal AppSettings GetAppSettings()
{
Models.Binder.AppSettings result = new()
{
BuildNumber = _AppSettings.BuildNumber,
Company = _AppSettings.Company,
GitCommitSeven = _AppSettings.GitCommitSeven,
IsDevelopment = _AppSettings.IsDevelopment,
IsStaging = _AppSettings.IsStaging,
};
AppSettings result = _AppSettings;
return result;
}
Models.Binder.AppSettings IAppSettingsRepository<Models.Binder.AppSettings>.GetAppSettings() => GetAppSettings();
AppSettings IAppSettingsRepository<AppSettings>.GetAppSettings() => GetAppSettings();
internal string GetBuildNumberAndGitCommitSeven()
{
@ -45,8 +38,8 @@ public class AppSettingsRepository : IAppSettingsRepository<Models.Binder.AppSet
#endif
}
string IAppSettingsRepository<Models.Binder.AppSettings>.GetBuildNumberAndGitCommitSeven() => GetBuildNumberAndGitCommitSeven();
string IAppSettingsRepository<AppSettings>.GetBuildNumberAndGitCommitSeven() => GetBuildNumberAndGitCommitSeven();
void IAppSettingsRepository<Models.Binder.AppSettings>.VerifyConnectionStrings() => VerifyConnectionStrings();
void IAppSettingsRepository<AppSettings>.VerifyConnectionStrings() => VerifyConnectionStrings();
}

158
Server/server-pipeline.yml Normal file
View File

@ -0,0 +1,158 @@
trigger:
branches:
include:
- master
paths:
include:
- Shared
- Server
variables:
runtime: 'win-x64'
coreVersion: 'net8.0'
nugetSource: 'https://artifactory.intra.infineon.com/artifactory/api/nuget/ngt-fi-package-main-vir/'
stages:
- stage: Development
displayName: Development
pool:
name: 'OpenInsight Metrology Viewer'
demands: OpenInsight-Metrology-Viewer-Server-Development
variables:
ASPNETCORE_ENVIRONMENT: 'Development'
assemblyTitle: 'OI.Metrology.Server'
configuration: 'Debug'
jobs:
- job: DebugDotnet
steps:
- script: |
echo Assembly Title: $(AssemblyTitle)
echo Build Id: $(Build.BuildId)
echo Build Reason: $(Build.Reason)
echo Repo Id: $(Build.Repository.Id)
echo Repo Name: $(Build.Repository.Name)
echo Source Version: $(Build.SourceVersion)
echo Configuration: $(Configuration)
echo Core Version: $(CoreVersion)
echo Nuget Source: $(NugetSource)
echo Runtime: $(Runtime)
displayName: 'Echo Check'
- script: |
dotnet user-secrets init
dotnet user-secrets set BuildNumber $(Build.BuildId)
dotnet user-secrets set GitCommit $(Build.SourceVersion)
dotnet user-secrets list
workingDirectory: Server
displayName: 'Server - Safe storage of app secrets'
- script: dotnet build --configuration $(Configuration) --source $(NugetSource)
workingDirectory: Server
displayName: 'Server - Build'
- script: dotnet build --configuration $(Configuration) --source $(NugetSource)
workingDirectory: Tests
displayName: 'Tests - Build'
- script: dotnet test --configuration $(Configuration)
workingDirectory: Tests
displayName: 'Tests - Test'
- script: dotnet publish --configuration $(Configuration)
workingDirectory: Server
displayName: 'Server - Publish'
enabled: false
- script: dotnet publish --configuration $(Configuration) --runtime $(Runtime) -p:PublishAot=true
workingDirectory: Server
displayName: 'Server - AOT Publish'
- task: CopyFiles@2
displayName: 'Copy Files to: D:\'
inputs:
Contents: "*"
SourceFolder: 'Server\bin\$(Configuration)\$(CoreVersion)\$(Runtime)\publish'
TargetFolder: 'D:\$(CoreVersion)\$(Runtime)\$(Build.Repository.Name)\$(Build.BuildId)\$(Configuration)-$(AssemblyTitle)-AOT'
OverWrite: true
- script: dotnet clean --configuration $(Configuration)
workingDirectory: Tests
displayName: 'Tests - Clean'
- script: dotnet clean --configuration $(Configuration)
workingDirectory: Server
displayName: 'Server - Clean'
- stage: Release
displayName: Release
pool:
name: 'OpenInsight Metrology Viewer'
demands: OpenInsight-Metrology-Viewer-Server
variables:
ASPNETCORE_ENVIRONMENT: 'Production'
assemblyTitle: 'OI.Metrology.Server'
configuration: 'Release'
jobs:
- job: ReleaseDotnet
steps:
- script: |
echo Assembly Title: $(AssemblyTitle)
echo Build Id: $(Build.BuildId)
echo Build Reason: $(Build.Reason)
echo Repo Id: $(Build.Repository.Id)
echo Repo Name: $(Build.Repository.Name)
echo Source Version: $(Build.SourceVersion)
echo Configuration: $(Configuration)
echo Core Version: $(CoreVersion)
echo Nuget Source: $(NugetSource)
echo Runtime: $(Runtime)
displayName: 'Echo Check'
- script: |
dotnet user-secrets init
dotnet user-secrets set BuildNumber $(Build.BuildId)
dotnet user-secrets set GitCommit $(Build.SourceVersion)
dotnet user-secrets list
workingDirectory: Server
displayName: 'Server - Safe storage of app secrets'
- script: dotnet build --configuration $(Configuration) --source $(NugetSource)
workingDirectory: Server
displayName: 'Server - Build'
- script: dotnet build --configuration $(Configuration) --source $(NugetSource)
workingDirectory: Tests
displayName: 'Tests - Build'
- script: dotnet test --configuration $(Configuration)
workingDirectory: Tests
displayName: 'Tests - Test'
- script: dotnet publish --configuration $(Configuration)
workingDirectory: Server
displayName: 'Server - Publish'
enabled: false
- script: dotnet publish --configuration $(Configuration) --runtime $(Runtime) -p:PublishAot=true
workingDirectory: Server
displayName: 'Server - AOT Publish'
- task: CopyFiles@2
displayName: 'Copy Files to: D:\'
inputs:
Contents: '*'
SourceFolder: 'Server\bin\$(Configuration)\$(CoreVersion)\$(Runtime)\publish'
TargetFolder: 'D:\$(CoreVersion)\$(Runtime)\$(Build.Repository.Name)\$(Build.BuildId)\$(Configuration)-$(AssemblyTitle)-AOT'
OverWrite: true
- script: dotnet clean --configuration $(Configuration)
workingDirectory: Tests
displayName: 'Tests - Clean'
- script: dotnet clean --configuration $(Configuration)
workingDirectory: Server
displayName: 'Server - Clean'
- script: 'echo $(Build.SourceVersion)-$(Build.BuildId)>bin_x_x_\$(Configuration)\$(CoreVersion)\win-x64\$(Build.Repository.Name).txt'
displayName: 'Force Fail'
enabled: false