<Project Sdk="Microsoft.NET.Sdk.Worker">

  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <OutputType>Exe</OutputType>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <RootNamespace>Mbproxy</RootNamespace>
    <AssemblyName>Mbproxy</AssemblyName>
    <!-- Assembly version. CI can override via /p:InformationalVersion=... -->
    <InformationalVersion>1.0.0</InformationalVersion>
  </PropertyGroup>

  <!-- Single-file self-contained publish (Release only; Debug stays normal for fast iteration).
       The resulting Mbproxy.exe is ~100 MB because the self-contained publish bundles the full
       .NET 10 + ASP.NET Core runtime — fixed cost of self-contained deployment on .NET 10 with
       ASP.NET Core. Operators who need a smaller footprint can use a framework-dependent publish
       (dotnet publish -c Release -r win-x64 -p:SelfContained=false -p:PublishSingleFile=true)
       if the target machine has .NET 10 installed. -->
  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <PublishSingleFile>true</PublishSingleFile>
    <SelfContained>true</SelfContained>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
  </PropertyGroup>

  <ItemGroup>
    <!-- ASP.NET Core for the Kestrel-hosted admin endpoint. -->
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

  <ItemGroup>
    <!-- Microsoft.Extensions.Hosting is already included transitively via
         Microsoft.AspNetCore.App — do not re-add it explicitly. -->
    <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="10.0.8" />
    <PackageReference Include="Serilog.Extensions.Hosting" Version="10.0.0" />
    <PackageReference Include="Serilog.Settings.Configuration" Version="10.0.0" />
    <PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
    <PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
    <!-- Polly: backend-connect retry pipeline (PolicyFactory.BuildBackendConnect) and
         listener-recovery pipeline (PolicyFactory.BuildListenerRecovery). -->
    <PackageReference Include="Polly" Version="8.6.6" />
  </ItemGroup>

  <ItemGroup>
    <!-- Allow test project to access internal types (HeartbeatWorker, HostingExtensions, etc.) -->
    <InternalsVisibleTo Include="Mbproxy.Tests" />
  </ItemGroup>

  <ItemGroup>
    <!-- Link the install template as the published appsettings.json so the binary ships
         with a fully-commented, usable example config (one PLC, one BCD tag, all sections
         present) instead of an empty stub. The .NET configuration loader supports JSONC
         (comments) under the default Host.CreateApplicationBuilder path, so the comments
         in the template are valid at runtime. -->
    <None Remove="appsettings.json" />
    <Content Include="..\..\install\mbproxy.config.template.json"
             Link="appsettings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

</Project>
