|
| 1 | +<Project Sdk="Microsoft.NET.Sdk.Web"> |
| 2 | + |
| 3 | + <PropertyGroup> |
| 4 | + <TargetFramework>net5.0</TargetFramework> |
| 5 | + <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> |
| 6 | + <TypeScriptToolsVersion>Latest</TypeScriptToolsVersion> |
| 7 | + <IsPackable>false</IsPackable> |
| 8 | + <SpaRoot>clientapp\</SpaRoot> |
| 9 | + <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes> |
| 10 | + <UserSecretsId>d2c17eee-1b0f-4bce-903d-b14d6dac95cc</UserSecretsId> |
| 11 | + </PropertyGroup> |
| 12 | + |
| 13 | + <ItemGroup> |
| 14 | + <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="5.0.2" /> |
| 15 | + <PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="3.1.11" /> |
| 16 | + <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="5.0.2" /> |
| 17 | + </ItemGroup> |
| 18 | + |
| 19 | + <ItemGroup> |
| 20 | + <!-- Don't publish the SPA source files, but do show them in the project files list --> |
| 21 | + <Content Remove="$(SpaRoot)**" /> |
| 22 | + <None Remove="$(SpaRoot)**" /> |
| 23 | + <None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" /> |
| 24 | + </ItemGroup> |
| 25 | + |
| 26 | + <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition="'$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') "> |
| 27 | + |
| 28 | + <!-- Ensure Node.js is installed --> |
| 29 | + <Exec Command="node --version" ContinueOnError="true"> |
| 30 | + <Output TaskParameter="ExitCode" PropertyName="ErrorCode" /> |
| 31 | + </Exec> |
| 32 | + |
| 33 | + <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." /> |
| 34 | + <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." /> |
| 35 | + <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /> |
| 36 | + </Target> |
| 37 | + |
| 38 | + <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish"> |
| 39 | + <!-- As part of publishing, ensure the JS resources are freshly built in production mode --> |
| 40 | + <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /> |
| 41 | + <Exec WorkingDirectory="$(SpaRoot)" Command="yarn build:iis" /> |
| 42 | + |
| 43 | + <!-- Include the newly-built files in the publish output --> |
| 44 | + <ItemGroup> |
| 45 | + <DistFiles Include="$(SpaRoot)build\**" /> |
| 46 | + <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)"> |
| 47 | + <RelativePath>%(DistFiles.Identity)</RelativePath> |
| 48 | + <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
| 49 | + <ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
| 50 | + </ResolvedFileToPublish> |
| 51 | + </ItemGroup> |
| 52 | + </Target> |
| 53 | + |
| 54 | + |
| 55 | +</Project> |
0 commit comments