I have an Angular7 app built has ServerSide Rendering (with angular universal) that is wrapped inside a .Net Core application and I'm unable to make the deploy to Azure App Service.
When I do the publish through Visual Studio, all the build is done correctly, creating the dist folder with
/dist
/browser
/server
server.js
but then the publish fails when copying the files from node_modules
to the obj folder.
Unable to copy file "C:\Work\Repos\website\msSite\ClientApp\node_modules.cache\terser-webpack-plugin\content-v2\sha512\8f\66\f49339db5275a13ef193d46e9a87afb770d173d93548f10a78 a493694695c748602741bec0e9f1f2c503f2d6e48f8034f4cc29da83d689f2f631af6938ba" to "C:\Work\Repos\we bsite\msSite\obj\Release\netcoreapp2.1\PubTmp\Out\ClientApp\node_modules.cache\terser-webpack-plugin\content-v2\sha512\8f\66\f49339db5275a13ef193d46e9a87afb770d173d93548f10a78a493694695c748602741bec0e9f1f2c503f2d6e4 8f8034f4cc29da83d689f2f631af6938ba". The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
AS I understand, because is server side rendering the node_modules are necessary but how can I resolve this problem?
this is part of the .csproj file
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --prod --aot" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr -- --prod" Condition=" '$(BuildServerSideRenderer)' == 'true' " />
<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" />
<DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" />
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>