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

    <PropertyGroup>
        <TargetFramework>net8.0</TargetFramework>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
        <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
        <BuildVersion>$([System.DateTime]::UtcNow.ToString("yyyy-MM-dd HH:mm:ss"))</BuildVersion>
    </PropertyGroup>

    <Target Name="GenerateCacheBustedIndexHtml" BeforeTargets="Build">
        <Exec Command="dotnet msbuild -t:ReplaceText -p:CacheBuster=$(CacheBuster);BuildVersion='$(BuildVersion)'" />
    </Target>

    <Target Name="ReplaceText">
        <Exec Command="sed 's/@CacheBuster/$(CacheBuster)/g;s/@BuildVersion/$(BuildVersion)/g' wwwroot/index.template.html > wwwroot/index.html" />
    </Target>

    <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
      <DocumentationFile>bin\Debug\net8.0\AliasVault.WebApp.xml</DocumentationFile>
      <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
      <CacheBuster>dev</CacheBuster>
    </PropertyGroup>

    <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
      <DebugSymbols>true</DebugSymbols>
      <DocumentationFile>bin\Release\net8.0\AliasVault.WebApp.xml</DocumentationFile>
      <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
      <Optimize>True</Optimize>
      <CacheBuster>$([System.DateTime]::UtcNow.ToString("yyyyMMddHHmmss"))</CacheBuster>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
        <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.6" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.6" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.6" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.6" PrivateAssets="all" />
        <PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
        <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
    </ItemGroup>

    <ItemGroup>
      <Content Update="wwwroot\appsettings.json">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </Content>
      <Content Include="..\..\.dockerignore">
        <Link>.dockerignore</Link>
      </Content>
      <AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" />
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\AliasDb\AliasDb.csproj" />
      <ProjectReference Include="..\AliasGenerators\AliasGenerators.csproj" />
      <ProjectReference Include="..\AliasVault.Shared\AliasVault.Shared.csproj" />
      <ProjectReference Include="..\Utilities\FaviconExtractor\FaviconExtractor.csproj" />
    </ItemGroup>

    <ItemGroup>
      <None Update="nginx.conf">
        <CopyToOutputDirectory>Never</CopyToOutputDirectory>
      </None>
    </ItemGroup>

    <ItemGroup>
      <Folder Include="Pages\Aliases\Mailbox\Models\" />
    </ItemGroup>
</Project>
