Self-contained build - keine .NET Installation noetig

This commit is contained in:
administrator 2026-05-01 23:15:14 +02:00
parent c963c4d9e9
commit 4493e6d0f1
5 changed files with 36 additions and 1 deletions

View file

@ -1,5 +1,7 @@
<Project>
<PropertyGroup>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<!-- Version aus Git-Tag lesen: git tag v1.2.3 → Version 1.2.3 -->
<GitVersion Condition="'$(GitVersion)' == ''">$([System.String]::Copy('1.0.0'))</GitVersion>
</PropertyGroup>

View file

@ -8,6 +8,10 @@
<RootNamespace>MailPrint</RootNamespace>
<AssemblyName>MailPrint</AssemblyName>
<OutputType>Exe</OutputType>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
<ItemGroup>

View file

@ -51,7 +51,34 @@ try
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
c.SwaggerDoc("v1", new() { Title = "MailPrint API", Version = "v1" }));
{
c.SwaggerDoc("v1", new() { Title = "MailPrint API", Version = "v1" });
// XML-Doku aus /// Kommentaren in OpenAPI uebernehmen
var xmlPath = Path.Combine(AppContext.BaseDirectory, "MailPrint.xml");
if (File.Exists(xmlPath))
c.IncludeXmlComments(xmlPath);
// API-Key-Security im Schema dokumentieren -> generierte Clients
// setzen den Header automatisch, Swagger UI hat Authorize-Button
var scheme = new Microsoft.OpenApi.Models.OpenApiSecurityScheme
{
Name = "X-Api-Key",
Type = Microsoft.OpenApi.Models.SecuritySchemeType.ApiKey,
In = Microsoft.OpenApi.Models.ParameterLocation.Header,
Description = "API-Key fuer alle /api/* Endpunkte. Konfiguriert in MailPrintConfig.",
Reference = new Microsoft.OpenApi.Models.OpenApiReference
{
Type = Microsoft.OpenApi.Models.ReferenceType.SecurityScheme,
Id = "ApiKey"
}
};
c.AddSecurityDefinition("ApiKey", scheme);
c.AddSecurityRequirement(new Microsoft.OpenApi.Models.OpenApiSecurityRequirement
{
[scheme] = Array.Empty<string>()
});
});
var app = builder.Build();
app.UseSwagger();

View file

@ -8,6 +8,8 @@
<UseWindowsForms>true</UseWindowsForms>
<RootNamespace>MailPrintConfig</RootNamespace>
<AssemblyName>MailPrintConfig</AssemblyName>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>

BIN
publish.zip Normal file

Binary file not shown.