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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Caching.CSRedis" Version="3.6.50" />
    <PackageReference Include="CSRedisCore" Version="3.6.5" />
    <PackageReference Include="DotNetZip" Version="1.15.0" />
    <PackageReference Include="HTEXLib" Version="2.3.4" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.6" />
      <PackageReference Include="VueCliMiddleware" Version="3.1.2" />  </ItemGroup>
  <PropertyGroup>
    <SpaRoot>ClientApp\</SpaRoot>
    <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
    <UserSecretsId>df088159-30c9-42c2-8385-46a7e7a93995</UserSecretsId>
  </PropertyGroup>
  <ItemGroup>
    <!-- Don't publish the SPA source files, but do show them in the project files list -->
    <Compile Remove="JsonFile\Subject\**" />
    <Compile Remove="logfile\**" />
    <Compile Remove="Models\SchoolInfo\**" />
    <Content Remove="$(SpaRoot)**" />
    
    <Content Remove="JsonFile\Subject\**" />
    
    <Content Remove="logfile\**" />
    
    <Content Remove="Models\SchoolInfo\**" />
    <None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Remove="JsonFile\Subject\**" />
    <EmbeddedResource Remove="logfile\**" />
    <EmbeddedResource Remove="Models\SchoolInfo\**" />
    <None Remove="JsonFile\Subject\**" />
    <None Remove="logfile\**" />
    <None Remove="Models\SchoolInfo\**" />
  </ItemGroup>
  <ItemGroup>
    <None Remove="ClientApp\src\static\BaseDataDefault.json" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="ClientApp\src\static\BaseDataDefault.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <Folder Include="JwtRsaFile\" />
    <Folder Include="Services\Evaluation\" />
  </ItemGroup>
  
  <ItemGroup>
    <ProjectReference Include="..\TEAMModelOS.SDK\TEAMModelOS.SDK.csproj" />
  </ItemGroup>

  <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build">
    <!-- Build Target:  Ensure Node.js is installed -->
    <Exec Command="node --version" ContinueOnError="true">
      <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
    </Exec>
    <Exec Command="npm --version" ContinueOnError="true">
      <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
    </Exec>
    <Error Condition="'$(ErrorCode)' != '0'" Text="Node.js and npm are 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." />
  </Target>

  <Target Name="EnsureNodeModulesInstalled" BeforeTargets="Build" Inputs="package.json" Outputs="packages-lock.json" Condition="!Exists('$(SpaRoot)node_modules')">
    <!-- Build Target: Restore NPM packages using npm -->
    <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
  </Target>

  <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
    <!-- Build Target: Run webpack dist build -->
    <Message Importance="high" Text="Running npm build..." />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build" />

    <!-- Include the newly-built files in the publish output -->
    <ItemGroup>
      <DistFiles Include="$(SpaRoot)dist\**" />
      <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
        <RelativePath>%(DistFiles.Identity)</RelativePath>
        <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
        <ExcludeFromSingleFile>True</ExcludeFromSingleFile>
      </ResolvedFileToPublish>
    </ItemGroup>
  </Target>

  <!--<ProjectExtensions><VisualStudio><UserProperties properties_4launchsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>-->
</Project>
