Skip to content

Commit 807d3fe

Browse files
committed
Improvements to ensure proper operation when utilizing Visual Studio IDE to Publish and Debug through the IDE.
The standard Debug menu option now works properly in accordance with folder structure (webpack, parent-based node_modules)
1 parent 81417cb commit 807d3fe

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

api/Properties/launchSettings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
"IIS Express": {
1212
"commandName": "IISExpress",
1313
"launchBrowser": true,
14+
"launchUrl": "http://localhost:5000",
1415
"environmentVariables": {
16+
"NODE_PATH": "../node_modules/",
1517
"ASPNETCORE_ENVIRONMENT": "Development"
1618
}
1719
},
1820
"api": {
1921
"commandName": "Project",
2022
"launchBrowser": true,
2123
"environmentVariables": {
24+
"NODE_PATH": "../node_modules/",
2225
"ASPNETCORE_ENVIRONMENT": "Development"
2326
},
2427
"applicationUrl": "http://localhost:5000/"

api/api.csproj

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,40 @@
2222
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
2323
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
2424
</ItemGroup>
25+
26+
27+
<Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' ">
28+
<Message Importance="high" Text="Installing any non-peer missing dependencies.." />
29+
<Exec Command="npm install" />
30+
31+
<!-- It would seem, that the npm install cmd targets the parent directory(natural path of the routine), and yet, the node webpack execution does not. So we go up one level -->
32+
<Message Importance="high" Text="Performing first-run Webpack build..." />
33+
<Exec Command="node ../node_modules/webpack/bin/webpack.js --config ../client-react/webpack.config.js" />
34+
35+
<Message Importance="high" Text="Starting up docker instances (if not started).." />
36+
<Exec Command="docker-compose up -d" />
37+
</Target>
38+
39+
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
40+
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
41+
<Exec Command="npm install" />
42+
<Exec Command="node ../node_modules/webpack/bin/webpack.js --config ../client-react/webpack.config.js --env.prod" />
43+
44+
<!-- Include the newly-built files in the publish output -->
45+
<ItemGroup>
46+
<DistFiles Include="wwwroot\*.js;" />
47+
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
48+
<RelativePath>%(DistFiles.Identity)</RelativePath>
49+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
50+
</ResolvedFileToPublish>
51+
</ItemGroup>
52+
53+
<ItemGroup Condition="'$(Configuration)'=='Debug'">
54+
<NpmFiles Include="..\node_modules\**;..\package.json;..\client-react\webpack.config.js;..\client-react\tsconfig.json;..\postcss.config.js;..\.babelrc" />
55+
<ResolvedFileToPublish Include="@(NpmFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
56+
<RelativePath>%(NpmFiles.Identity)</RelativePath>
57+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
58+
</ResolvedFileToPublish>
59+
</ItemGroup>
60+
</Target>
2561
</Project>

0 commit comments

Comments
 (0)