<Project>
  <PropertyGroup>
    <!-- Major.Minor set manually on each minor/major bump. Patch is auto-counted from git tag v$(WKAppBotBaseVersion). -->
<WKAppBotBaseVersion>7.4</WKAppBotBaseVersion>
    <WKAppBotVersion>$(WKAppBotBaseVersion).0</WKAppBotVersion>
    <!-- Treat warnings as errors in Release builds -->
    <TreatWarningsAsErrors Condition="'$(Configuration)' == 'Release'">true</TreatWarningsAsErrors>
    <!-- Nullable references enabled globally -->
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <!--
    Auto-patch: no tags needed.
    Finds the commit that introduced the current WKAppBotBaseVersion value via git pickaxe (-S),
    then counts commits since that point. Just bump WKAppBotBaseVersion — done.
  -->
  <Target Name="_WKAutoVersion" BeforeTargets="GetAssemblyVersion">
    <!-- Find the commit where WKAppBotBaseVersion was set to current value -->
    <Exec Command="git log -1 --format=%%H -S &quot;&lt;WKAppBotBaseVersion&gt;$(WKAppBotBaseVersion)&lt;/WKAppBotBaseVersion&gt;&quot; -- Directory.Build.props"
          ConsoleToMSBuild="true"
          IgnoreExitCode="true"
          WorkingDirectory="$(MSBuildThisFileDirectory)">
      <Output TaskParameter="ConsoleOutput" PropertyName="_WKBumpCommit" />
    </Exec>
    <!-- Count only source-touching commits since the bump (docs/md/txt excluded) -->
    <Exec Command="git rev-list --count $(_WKBumpCommit.Trim())..HEAD -- &quot;*.cs&quot; &quot;*.csproj&quot; &quot;*.props&quot; &quot;*.yaml&quot;"
          ConsoleToMSBuild="true"
          IgnoreExitCode="true"
          WorkingDirectory="$(MSBuildThisFileDirectory)"
          Condition="'$(_WKBumpCommit.Trim())' != ''">
      <Output TaskParameter="ConsoleOutput" PropertyName="_WKPatch" />
    </Exec>
    <Warning Condition="'$(_WKBumpCommit.Trim())' == ''"
             Text="[WKAppBot] Could not find bump commit for v$(WKAppBotBaseVersion) — patch defaults to 0." />
    <PropertyGroup>
      <!-- Fallback: empty or non-numeric (e.g. git not in PATH during AOT build) → 0 -->
      <_WKPatch Condition="'$(_WKPatch.Trim())' == '' Or '$([System.Text.RegularExpressions.Regex]::IsMatch($(_WKPatch.Trim()), `^\d+$`))' == 'false'">0</_WKPatch>
      <Version>$(WKAppBotBaseVersion).$(_WKPatch.Trim())</Version>
      <WKAppBotVersion>$(Version)</WKAppBotVersion>
    </PropertyGroup>
    <Message Text="[WKAppBot] version: $(WKAppBotVersion)" Importance="normal" />
  </Target>
</Project>
