Kyoo/src/Kyoo.WebApp/Kyoo.WebApp.csproj

81 lines
3.3 KiB
XML

<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>default</LangVersion>
<AssemblyName>Kyoo.WebApp</AssemblyName>
<RootNamespace>Kyoo.WebApp</RootNamespace>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules/**</DefaultItemExcludes>
<SpaRoot>Front/</SpaRoot>
<Icons>../../icons/</Icons>
<NpmStamp>$(SpaRoot)node_modules/.install-stamp</NpmStamp>
<!-- Set this to true if you enable server-side prerendering -->
<BuildServerSideRenderer>false</BuildServerSideRenderer>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="5.0.0-preview.8.20414.8" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="5.0.8" />
<ProjectReference Include="../Kyoo.Abstractions/Kyoo.Abstractions.csproj" />
</ItemGroup>
<ItemGroup>
<Content Remove="$(SpaRoot)**" />
<Compile Remove="$(SpaRoot)**" />
<None Remove="$(SpaRoot)dist/**; $(SpaRoot)dist-server/**" />
<Content Include="$(Icons)**" Visible="false">
<Link>wwwroot/%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="$(SpaRoot)static/**" Visible="false">
<Link>wwwroot/%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Target Name="NpmInstall" BeforeTargets="RunWebpack" Inputs="$(SpaRoot)/package.json" Outputs="$(NpmStamp)" Condition="$(SkipWebApp) != true">
<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 'npm'. This may take several minutes..." />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
<Touch Files="$(NpmStamp)" AlwaysCreate="true" />
</Target>
<Target Name="RunWebpack" Condition="'$(SkipWebApp)' != 'true' And '$(Configuration)' == 'Release'">
<Message Importance="high" Text="Building the web app. This may take several minutes..." />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --prod" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr -- --prod" Condition="'$(BuildServerSideRenderer)' == 'true'" />
</Target>
<Target Name="CopyFrontEndFiles" AfterTargets="RunWebpack" BeforeTargets="GetCopyToOutputDirectoryItems" Condition="'$(Configuration)' != 'Debug'">
<ItemGroup>
<NewContent Include="$(SpaRoot)dist/**; $(SpaRoot)dist-server/**" Visible="false" />
<Content Include="@(NewContent)">
<Link>wwwroot/%(NewContent.RecursiveDir)%(NewContent.Filename)%(NewContent.Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Target>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<BuildDependsOn>
NpmInstall;
RunWebpack;
$(BuildDependsOn)
</BuildDependsOn>
</PropertyGroup>
</Project>