diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index b59f6cd..3ade5de 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -34,7 +34,7 @@ jobs:
- name: Publish WinCertInstaller
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
- run: dotnet publish WinCertInstaller/WinCertInstaller.csproj -c Release -r win-x64 --self-contained false -p:PublishSingleFile=true -o ./publish
+ run: dotnet publish WinCertInstaller/WinCertInstaller.csproj -c Release -r win-x64 -o ./publish
- name: Upload Artifact
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
@@ -48,6 +48,6 @@ jobs:
shell: pwsh
run: |
$tag = $env:GITHUB_REF -replace 'refs/tags/', ''
- gh release create $tag ./publish/WinCertInstaller.exe ./publish/appsettings.json --title "Release $tag" --notes "Automated release for version $tag"
+ gh release create $tag ./publish/WinCertInstaller.exe --title "Release $tag" --notes "Automated release for version $tag"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/WinCertInstaller/Configuration/AppSettings.cs b/WinCertInstaller/Configuration/AppSettings.cs
index 72d916a..a2c453f 100644
--- a/WinCertInstaller/Configuration/AppSettings.cs
+++ b/WinCertInstaller/Configuration/AppSettings.cs
@@ -14,11 +14,11 @@ public class AppSettings
///
/// The URL to the ZIP file containing ITI (ICP-Brasil) certificates.
///
- public string ITICertUrl { get; set; } = string.Empty;
+ public string ITICertUrl { get; set; } = "http://acraiz.icpbrasil.gov.br/credenciadas/CertificadosAC-ICP-Brasil/ACcompactado.zip";
///
/// The URL to the P7B (PKCS #7) file containing MPF certificates.
///
- public string MPFCertUrl { get; set; } = string.Empty;
+ public string MPFCertUrl { get; set; } = "http://repositorio.acinterna.mpf.mp.br/ejbca/ra/downloads/ACIMPF-cadeia-completa.p7b";
}
}
diff --git a/WinCertInstaller/Configuration/AppSettingsJsonContext.cs b/WinCertInstaller/Configuration/AppSettingsJsonContext.cs
new file mode 100644
index 0000000..f298d7b
--- /dev/null
+++ b/WinCertInstaller/Configuration/AppSettingsJsonContext.cs
@@ -0,0 +1,10 @@
+using System.Text.Json.Serialization;
+using WinCertInstaller.Configuration;
+
+namespace WinCertInstaller.Configuration
+{
+ [JsonSerializable(typeof(AppSettings))]
+ internal partial class AppSettingsJsonContext : JsonSerializerContext
+ {
+ }
+}
diff --git a/WinCertInstaller/Program.cs b/WinCertInstaller/Program.cs
index bc48268..3593ddb 100644
--- a/WinCertInstaller/Program.cs
+++ b/WinCertInstaller/Program.cs
@@ -195,30 +195,19 @@ private static AppSettings LoadSettings()
try
{
string json = File.ReadAllText(configPath);
+ if (string.IsNullOrWhiteSpace(json)) return new AppSettings();
+
using var doc = JsonDocument.Parse(json);
var root = doc.RootElement;
- var settings = new AppSettings();
-
+ // Try to get the "CertificateSources" property if it exists (nested structure support)
if (root.TryGetProperty("CertificateSources", out var sources))
{
- if (sources.TryGetProperty("ITICertUrl", out var itiUrl))
- settings.ITICertUrl = itiUrl.GetString() ?? string.Empty;
-
- if (sources.TryGetProperty("MPFCertUrl", out var mpfUrl))
- settings.MPFCertUrl = mpfUrl.GetString() ?? string.Empty;
- }
- else
- {
- // Fallback to root level if not nested
- if (root.TryGetProperty("ITICertUrl", out var itiUrl))
- settings.ITICertUrl = itiUrl.GetString() ?? string.Empty;
-
- if (root.TryGetProperty("MPFCertUrl", out var mpfUrl))
- settings.MPFCertUrl = mpfUrl.GetString() ?? string.Empty;
+ return JsonSerializer.Deserialize(sources.GetRawText(), AppSettingsJsonContext.Default.AppSettings) ?? new AppSettings();
}
-
- return settings;
+
+ // Try to deserialize from the root (flat structure support)
+ return JsonSerializer.Deserialize(json, AppSettingsJsonContext.Default.AppSettings) ?? new AppSettings();
}
catch
{
diff --git a/WinCertInstaller/WinCertInstaller.csproj b/WinCertInstaller/WinCertInstaller.csproj
index 6110ca7..e2d1ce1 100644
--- a/WinCertInstaller/WinCertInstaller.csproj
+++ b/WinCertInstaller/WinCertInstaller.csproj
@@ -9,10 +9,11 @@
WinCertInstaller
false
app.manifest
- win-x64
- false
- true
- true
+ true
+ true
+ false
+ true
+ Size
@@ -20,8 +21,5 @@
-
- Always
-
\ No newline at end of file
diff --git a/WinCertInstaller/appsettings.json b/WinCertInstaller/appsettings.json
deleted file mode 100644
index 522d697..0000000
--- a/WinCertInstaller/appsettings.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
- },
- "CertificateSources": {
- "ITICertUrl": "http://acraiz.icpbrasil.gov.br/credenciadas/CertificadosAC-ICP-Brasil/ACcompactado.zip",
- "MPFCertUrl": "http://repositorio.acinterna.mpf.mp.br/ejbca/ra/downloads/ACIMPF-cadeia-completa.p7b"
- }
-}
diff --git a/publish_optimized/appsettings.json b/publish_optimized/appsettings.json
deleted file mode 100644
index 522d697..0000000
--- a/publish_optimized/appsettings.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
- },
- "CertificateSources": {
- "ITICertUrl": "http://acraiz.icpbrasil.gov.br/credenciadas/CertificadosAC-ICP-Brasil/ACcompactado.zip",
- "MPFCertUrl": "http://repositorio.acinterna.mpf.mp.br/ejbca/ra/downloads/ACIMPF-cadeia-completa.p7b"
- }
-}