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

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net8.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <LangVersion>latest</LangVersion>
    <AssemblyName>PSLauncher.Updater</AssemblyName>
    <RootNamespace>PSLauncher.Updater</RootNamespace>
    <Version>0.5.0</Version>

    <!-- Single-file self-contained pour le publish (~10 Mo) -->
    <PublishSingleFile>true</PublishSingleFile>
    <SelfContained>true</SelfContained>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
    <EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
    <PublishTrimmed>false</PublishTrimmed>
  </PropertyGroup>

  <!-- Copie automatique du single-file Updater à la racine du repo après chaque
       `dotnet publish -c Release`. -->
  <Target Name="CopyPublishedToRepoRoot" AfterTargets="Publish"
          Condition=" '$(Configuration)' == 'Release' ">
    <PropertyGroup>
      <RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\'))</RepoRoot>
    </PropertyGroup>
    <Copy SourceFiles="$(PublishDir)$(AssemblyName).exe"
          DestinationFolder="$(RepoRoot)"
          SkipUnchangedFiles="false"
          OverwriteReadOnlyFiles="true" />
    <Message Importance="high" Text="Copied $(AssemblyName).exe to $(RepoRoot)" />
  </Target>

</Project>
