"dotnet publish" strips out angular-specific tags used for CSS #93

Closed
opened 2025-08-09 17:14:58 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @sjetha-pason on 4/18/2018

Problem
When using "dotnet publish" to publish and the pack our project for deployment, the DOM-related tags in our Angular 4 project are stripped out. This affects some of our components that assume that the parent elements have styling, namely that they have their height set to 100%.

Build process that works:
C:\Dev\MPS\mps [RMS-5200 ↑5 +1 ~4 -0 !]> npm run-script build

MPS2@0.0.0-alpha1 build C:\Dev\MPS\mps
dotnet build && webpack --config webpack.config.vendor.js && webpack

Microsoft (R) Build Engine version 15.7.11.29948 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 66.74 ms for C:\Dev\MPS\mps\mps.csproj.
Restore completed in 70.16 ms for C:\Dev\MPS\mps\mps.csproj.
Restore completed in 124.07 ms for C:\Dev\MPS\mps\mps.csproj.
mps -> C:\Dev\MPS\mps\bin\Debug\netcoreapp2.0\mps.dll

Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:03.17
Hash: 9aa766adcb359798b0c94a20433964185280358e
Version: webpack 2.7.0
Child
Hash: 9aa766adcb359798b0c9
Time: 6313ms
Asset Size Chunks Chunk Names
89889688147bd7575d6327160d64e760.svg 109 kB [emitted]
vendor.js 3.33 MB 0 [emitted] [big] vendor
vendor.css 406 kB 0 [emitted] [big] vendor
Child
Hash: 4a20433964185280358e
Time: 6294ms
Asset Size Chunks Chunk Names
89889688147bd7575d6327160d64e760.svg 109 kB [emitted]
vendor.js 3.6 MB 0 [emitted] [big] vendor
Hash: 729bea1577a4663ba9ce957cdd3206cc36698112
Version: webpack 2.7.0
Child
Hash: 729bea1577a4663ba9ce
Time: 32732ms
Asset Size Chunks Chunk Names
main-client.js 2.16 MB 0 [emitted] [big] main-client
main-client.js.map 2.55 MB 0 [emitted] main-client
Child
Hash: 957cdd3206cc36698112
Time: 32723ms
Asset Size Chunks Chunk Names
main-server.js 6.66 MB 0 [emitted] [big] main-server
C:\Dev\MPS\mps [RMS-5200 ↑5 +1 ~4 -0 !]> dotnet run
Using launch settings from C:\Dev\MPS\mps\Properties\launchSettings.json...
Hosting environment: Production
Content root path: C:\Dev\MPS\mps
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

Note the _nghost and _ngcontent tags present in the source code below:
image

Build/publish process that doesn't work
C:\Dev\MPS\mps [RMS-5200 ↑5 +1 ~4 -0 !]> dotnet publish
Microsoft (R) Build Engine version 15.7.11.29948 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 75.6 ms for C:\Dev\MPS\mps\mps.csproj.
Restore completed in 81.61 ms for C:\Dev\MPS\mps\mps.csproj.
Restore completed in 130.46 ms for C:\Dev\MPS\mps\mps.csproj.
mps -> C:\Dev\MPS\mps\bin\Debug\netcoreapp2.0\mps.dll
up to date in 11.459s
Hash: b2a50760c2c3639f51b8c69736d35fa559760d6a
Version: webpack 2.7.0
Child
Hash: b2a50760c2c3639f51b8
Time: 25133ms
Asset Size Chunks Chunk Names
89889688147bd7575d6327160d64e760.svg 109 kB [emitted]
vendor.js 194 kB 0 [emitted] vendor
vendor.css 365 kB 0 [emitted] [big] vendor
Child
Hash: c69736d35fa559760d6a
Time: 25241ms
Asset Size Chunks Chunk Names
89889688147bd7575d6327160d64e760.svg 109 kB [emitted]
vendor.js 3.54 MB 0 [emitted] [big] vendor
Hash: d39aed335f5e65006542dc55b5d8250b61e440aa
Version: webpack 2.7.0
Child
Hash: d39aed335f5e65006542
Time: 37211ms
Asset Size Chunks Chunk Names
main-client.js 1.47 MB 0 [emitted] [big] main-client
Child
Hash: dc55b5d8250b61e440aa
Time: 37203ms
Asset Size Chunks Chunk Names
main-server.js 7.2 MB 0 [emitted] [big] main-server
mps -> C:\Dev\MPS\mps\bin\Debug\netcoreapp2.0\publish
C:\Dev\MPS\mps [RMS-5200 ↑5 +1 ~4 -0 !]> cd .\bin\Debug\netcoreapp2.0\publish
C:\Dev\MPS\mps\bin\Debug\netcoreapp2.0\publish [RMS-5200 ↑5 +1 ~4 -0 !]> dotnet .\mps.dll
Hosting environment: Production
Content root path: C:\Dev\MPS\mps\bin\Debug\netcoreapp2.0\publish
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

Note that the _ng tags are now missing from the source code:
image

*Originally created by @sjetha-pason on 4/18/2018* *Problem* When using "dotnet publish" to publish and the pack our project for deployment, the DOM-related tags in our Angular 4 project are stripped out. This affects some of our components that assume that the parent elements have styling, namely that they have their height set to 100%. Build process that works: C:\Dev\MPS\mps [RMS-5200 ↑5 +1 ~4 -0 !]> npm run-script build > MPS2@0.0.0-alpha1 build C:\Dev\MPS\mps > dotnet build && webpack --config webpack.config.vendor.js && webpack Microsoft (R) Build Engine version 15.7.11.29948 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved. Restore completed in 66.74 ms for C:\Dev\MPS\mps\mps.csproj. Restore completed in 70.16 ms for C:\Dev\MPS\mps\mps.csproj. Restore completed in 124.07 ms for C:\Dev\MPS\mps\mps.csproj. mps -> C:\Dev\MPS\mps\bin\Debug\netcoreapp2.0\mps.dll Build succeeded. 0 Warning(s) 0 Error(s) Time Elapsed 00:00:03.17 Hash: 9aa766adcb359798b0c94a20433964185280358e Version: webpack 2.7.0 Child Hash: 9aa766adcb359798b0c9 Time: 6313ms Asset Size Chunks Chunk Names 89889688147bd7575d6327160d64e760.svg 109 kB [emitted] vendor.js 3.33 MB 0 [emitted] [big] vendor vendor.css 406 kB 0 [emitted] [big] vendor Child Hash: 4a20433964185280358e Time: 6294ms Asset Size Chunks Chunk Names 89889688147bd7575d6327160d64e760.svg 109 kB [emitted] vendor.js 3.6 MB 0 [emitted] [big] vendor Hash: 729bea1577a4663ba9ce957cdd3206cc36698112 Version: webpack 2.7.0 Child Hash: 729bea1577a4663ba9ce Time: 32732ms Asset Size Chunks Chunk Names main-client.js 2.16 MB 0 [emitted] [big] main-client main-client.js.map 2.55 MB 0 [emitted] main-client Child Hash: 957cdd3206cc36698112 Time: 32723ms Asset Size Chunks Chunk Names main-server.js 6.66 MB 0 [emitted] [big] main-server C:\Dev\MPS\mps [RMS-5200 ↑5 +1 ~4 -0 !]> dotnet run Using launch settings from C:\Dev\MPS\mps\Properties\launchSettings.json... Hosting environment: Production Content root path: C:\Dev\MPS\mps Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down. Note the _nghost and _ngcontent tags present in the source code below: ![image](https://user-images.githubusercontent.com/11927856/38945511-ea9db326-42f3-11e8-8ee2-e574b5d46f9f.png) Build/publish process that doesn't work C:\Dev\MPS\mps [RMS-5200 ↑5 +1 ~4 -0 !]> dotnet publish Microsoft (R) Build Engine version 15.7.11.29948 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved. Restore completed in 75.6 ms for C:\Dev\MPS\mps\mps.csproj. Restore completed in 81.61 ms for C:\Dev\MPS\mps\mps.csproj. Restore completed in 130.46 ms for C:\Dev\MPS\mps\mps.csproj. mps -> C:\Dev\MPS\mps\bin\Debug\netcoreapp2.0\mps.dll up to date in 11.459s Hash: b2a50760c2c3639f51b8c69736d35fa559760d6a Version: webpack 2.7.0 Child Hash: b2a50760c2c3639f51b8 Time: 25133ms Asset Size Chunks Chunk Names 89889688147bd7575d6327160d64e760.svg 109 kB [emitted] vendor.js 194 kB 0 [emitted] vendor vendor.css 365 kB 0 [emitted] [big] vendor Child Hash: c69736d35fa559760d6a Time: 25241ms Asset Size Chunks Chunk Names 89889688147bd7575d6327160d64e760.svg 109 kB [emitted] vendor.js 3.54 MB 0 [emitted] [big] vendor Hash: d39aed335f5e65006542dc55b5d8250b61e440aa Version: webpack 2.7.0 Child Hash: d39aed335f5e65006542 Time: 37211ms Asset Size Chunks Chunk Names main-client.js 1.47 MB 0 [emitted] [big] main-client Child Hash: dc55b5d8250b61e440aa Time: 37203ms Asset Size Chunks Chunk Names main-server.js 7.2 MB 0 [emitted] [big] main-server mps -> C:\Dev\MPS\mps\bin\Debug\netcoreapp2.0\publish\ C:\Dev\MPS\mps [RMS-5200 ↑5 +1 ~4 -0 !]> cd .\bin\Debug\netcoreapp2.0\publish\ C:\Dev\MPS\mps\bin\Debug\netcoreapp2.0\publish [RMS-5200 ↑5 +1 ~4 -0 !]> dotnet .\mps.dll Hosting environment: Production Content root path: C:\Dev\MPS\mps\bin\Debug\netcoreapp2.0\publish Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down. Note that the _ng tags are now missing from the source code: ![image](https://user-images.githubusercontent.com/11927856/38945654-6854fe1e-42f4-11e8-8f70-e1ce7f2ee510.png)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#93
No description provided.