|
| 1 | +<Project Sdk="Microsoft.NET.Sdk.Web"> |
| 2 | + |
| 3 | + <PropertyGroup> |
| 4 | + <TargetFramework>netcoreapp2.0</TargetFramework> |
| 5 | + <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> |
| 6 | + <TypeScriptToolsVersion>Latest</TypeScriptToolsVersion> |
| 7 | + <IsPackable>false</IsPackable> |
| 8 | + </PropertyGroup> |
| 9 | + |
| 10 | + <ItemGroup> |
| 11 | + <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" /> |
| 12 | + </ItemGroup> |
| 13 | + |
| 14 | + <ItemGroup> |
| 15 | + <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" /> |
| 16 | + </ItemGroup> |
| 17 | + |
| 18 | + <ItemGroup> |
| 19 | + <!-- Files not to publish (note that the 'dist' subfolders are re-added below) --> |
| 20 | + <Content Remove="ClientApp\**" /> |
| 21 | + </ItemGroup> |
| 22 | + |
| 23 | + <Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('wwwroot\dist') "> |
| 24 | + <!-- Ensure Node.js is installed --> |
| 25 | + <Exec Command="node --version" ContinueOnError="true"> |
| 26 | + <Output TaskParameter="ExitCode" PropertyName="ErrorCode" /> |
| 27 | + </Exec> |
| 28 | + <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." /> |
| 29 | + |
| 30 | + <!-- In development, the dist files won't exist on the first run or when cloning to |
| 31 | + a different machine, so rebuild them if not already present. --> |
| 32 | + <Message Importance="high" Text="Performing first-run Webpack build..." /> |
| 33 | + <Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" /> |
| 34 | + <Exec Command="node node_modules/webpack/bin/webpack.js" /> |
| 35 | + </Target> |
| 36 | + |
| 37 | + <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish"> |
| 38 | + <!-- As part of publishing, ensure the JS resources are freshly built in production mode --> |
| 39 | + <Exec Command="npm install" /> |
| 40 | + <Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" /> |
| 41 | + <Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" /> |
| 42 | + |
| 43 | + <!-- Include the newly-built files in the publish output --> |
| 44 | + <ItemGroup> |
| 45 | + <DistFiles Include="wwwroot\dist\**; ClientApp\dist\**" /> |
| 46 | + <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)"> |
| 47 | + <RelativePath>%(DistFiles.Identity)</RelativePath> |
| 48 | + <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
| 49 | + </ResolvedFileToPublish> |
| 50 | + </ItemGroup> |
| 51 | + </Target> |
| 52 | + |
| 53 | +</Project> |
0 commit comments