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

    <PropertyGroup>
        <TargetFramework>net8.0</TargetFramework>
        <Nullable>enable</Nullable>
        <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
        <TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
        <IsPackable>false</IsPackable>
        <SpaRoot>frontend\</SpaRoot>
        <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
        <SpaProxyServerUrl>https://localhost:44478</SpaProxyServerUrl>
        <SpaProxyLaunchCommand>yarn start</SpaProxyLaunchCommand>
        <ImplicitUsings>enable</ImplicitUsings>
        <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
        <LangVersion>12</LangVersion>
        <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="AspNet.Security.OAuth.Discord" Version="8.0.0" />
        <PackageReference Include="Grpc.Core" Version="2.46.6" />
        <PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="8.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="8.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="8.0.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
          <PrivateAssets>all</PrivateAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
        <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
        <PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.7.0" />
        <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" />
        <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
        <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
    </ItemGroup>
    
    <ItemGroup>
        <!-- Don't publish the SPA source files, but do show them in the project files list -->
        <Content Remove="$(SpaRoot)**" />
        <Content Include="..\.dockerignore">
          <Link>.dockerignore</Link>
        </Content>
        <None Remove="$(SpaRoot)**" />
        <None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
    </ItemGroup>
    
    <ItemGroup>
      <Folder Include="Services\FirstEdition\" />
    </ItemGroup>

    <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
        <!-- Ensure Node.js is installed -->
        <Exec Command="node --version" ContinueOnError="true">
            <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
        </Exec>
        <Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
        <Message Importance="high" Text="Restoring dependencies using 'yarn'. This may take several minutes..." />
        <Exec WorkingDirectory="$(SpaRoot)" Command="yarn install" />
    </Target>
    
</Project>
